├── .idea ├── SystolicPressure.iml ├── misc.xml ├── modules.xml ├── vcs.xml └── workspace.xml ├── main.py ├── ppg_params.mat ├── ppg_params_new.mat ├── systolicpres.mat └── systolicpres_new.mat /.idea/SystolicPressure.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 64 | 65 | 73 | 74 | 75 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 104 | 105 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 128 | 129 | 130 | 131 | 148 | 149 | 166 | 167 | 185 | 186 | 203 | 204 | 215 | 216 | 234 | 235 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 266 | 267 | 268 | 269 | 1527592010381 270 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 303 | 304 | 305 | 306 | 307 | 308 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import scipy.io as sio 2 | from scipy import signal as sig 3 | import numpy as np 4 | import tensorflow as tf 5 | 6 | matpath = 'C:/Users/Vlad/Desktop/Machine Learning/Projects/SystolicPressure/' 7 | filename_sp = 'systolicpres.mat' 8 | filename_params = 'ppg_params.mat' 9 | 10 | systolic_pressure = sio.loadmat(matpath + filename_sp) 11 | ppg_params = sio.loadmat(matpath + filename_params) 12 | 13 | def feature_normalize(X): 14 | mean = np.mean(X, axis=0) 15 | std = np.std(X, axis=0) 16 | return (X - mean) / std 17 | 18 | y_data = np.transpose(systolic_pressure.get('BP_l')) 19 | y_train = y_data[0:500, :] 20 | y_test = y_data[500:, :] 21 | 22 | x_data = np.transpose(ppg_params.get('PeakSys_l')) 23 | x_data = feature_normalize(x_data) 24 | x_train = x_data[0:500, :] 25 | x_test = x_data[500:, :] 26 | 27 | print(x_data) 28 | 29 | def hiddenlayer(x_input, input_size, output_size): 30 | W = tf.Variable(tf.truncated_normal([input_size, output_size], stddev = 0.01)) 31 | b = tf.Variable(tf.truncated_normal([1], stddev = 0.01)) 32 | return tf.matmul(x_input, W) + b 33 | 34 | with tf.variable_scope('Initialization'): 35 | n_epoch, n_hidden = 100000000, 10 36 | n_row, n_col = np.shape(x_train) 37 | n_row_test, n_col_test = np.shape(x_test) 38 | n_input = n_row 39 | y_input = tf.placeholder(tf.float32, [None, 1]) 40 | x_input = tf.placeholder(tf.float32, [None, n_col]) 41 | h1 = tf.sigmoid(hiddenlayer(x_input, n_col, n_hidden)) 42 | y_pred = hiddenlayer(h1, n_hidden, 1) 43 | 44 | 45 | loss_function = tf.reduce_sum(tf.square(y_pred - y_input) / (2 * n_input)) 46 | train = tf.train.GradientDescentOptimizer(0.0002).minimize(loss_function) 47 | 48 | loss_history = [] 49 | result = [] 50 | with tf.Session() as sess: 51 | sess.run(tf.global_variables_initializer()) 52 | for epoch in range(n_epoch): 53 | _, loss = sess.run([train, loss_function], feed_dict={x_input: x_train, y_input: y_train}) 54 | loss_history.append(loss) 55 | print("Epoch: ", epoch, ", loss: ", loss) 56 | 57 | print(n_row_test, n_col_test) 58 | x_test = x_test.reshape(n_row_test, n_col_test) 59 | print(np.shape(x_test)) 60 | for i in range(n_row_test): 61 | x_to_feed = x_test[i,:].reshape(1, n_col_test) 62 | result.append(sess.run(y_pred, feed_dict={x_input: x_to_feed})) 63 | 64 | 65 | np.save('C:/Users/Vlad/Desktop/Machine Learning/Projects/SystolicPressure/' + 'loss_history.npy', loss_history) 66 | np.save('C:/Users/Vlad/Desktop/Machine Learning/Projects/SystolicPressure/' + 'result_prediction.npy', result) -------------------------------------------------------------------------------- /ppg_params.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gagampy/Machine-Learning---Multivariable-Regression/a5be88654740bc97b48a721e1ab8485f3a133f97/ppg_params.mat -------------------------------------------------------------------------------- /ppg_params_new.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gagampy/Machine-Learning---Multivariable-Regression/a5be88654740bc97b48a721e1ab8485f3a133f97/ppg_params_new.mat -------------------------------------------------------------------------------- /systolicpres.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gagampy/Machine-Learning---Multivariable-Regression/a5be88654740bc97b48a721e1ab8485f3a133f97/systolicpres.mat -------------------------------------------------------------------------------- /systolicpres_new.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gagampy/Machine-Learning---Multivariable-Regression/a5be88654740bc97b48a721e1ab8485f3a133f97/systolicpres_new.mat --------------------------------------------------------------------------------