Skip to content

Commit

Permalink
Clean code test_HR notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
trinhgiahuy authored Oct 24, 2022
1 parent 08ce448 commit 434198e
Showing 1 changed file with 6 additions and 76 deletions.
82 changes: 6 additions & 76 deletions 1_measure_files/Automatic_subj_training-test_HR.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
},
{
"cell_type": "markdown",
"id": "9bd581cf",
"id": "48fdef95",
"metadata": {},
"source": [
"## Defilne parser function"
Expand All @@ -133,7 +133,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "48b9ab0d",
"id": "e95b0608",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -195,7 +195,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 19,
"id": "9be7b2e8",
"metadata": {
"scrolled": true
Expand All @@ -208,16 +208,6 @@
"The time step now should be 2\n",
"5 input features included: speed, speedChange, stepDuration, vertOscillation_dist_amp, heart rate\n"
]
},
{
"data": {
"text/plain": [
"' \\nlist_test=[]\\nfor i in range(len(test)):\\n test[i]=np.transpose(np.array(test[i]))\\n list_test.append(test[i])\\n\\nfor j in range(len(test2)): \\n test2[j]=np.transpose(np.array(test2[j]))\\n list_test.append(test2[j]) \\n\\n \\nprint(np.shape(list_test))\\nlist_test=np.vstack(list_test)\\nprint(np.shape(list_test))\\nscaler = StandardScaler()\\nscaler=scaler.fit(list_test)\\nscaled_list_test=scaler.transform(list_test)\\nprint(np.shape(scaled_list_test))\\nXT_s_stack=list()\\ni=0\\nwhile i+50 <= (len(scaled_list_test)):\\n XT_s_stack.append(scaled_list_test[i:i+50])\\n i=i+50\\n\\n\\nXT_s_stack=np.stack(XT_s_stack)\\n\\ncutPoint=np.shape(TTest.reshape(-1))[0]\\n\\nXTrain_s=XT_s_stack[:-cutPoint,:,:]\\nXTest_s=XT_s_stack[-cutPoint:,:,:]\\n\\nTest=np.transpose(TTest)\\n\\nprint(np.shape(XTrain_s))\\n'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
Expand Down Expand Up @@ -267,49 +257,12 @@
"# Automatically setting name of output files based on configuration \n",
"modelSaveName=confPrefix+'Subj-'+subjectID+'-'+str(noEpochs)+'pochs-'+orderedPrefix+str(noLSTMUnits)+'-LSTM_u.h5'\n",
"figPredictName=confPrefix+'Subj'+subjectID+'-'+str(noEpochs)+'pochs-'+orderedPrefix+str(noLSTMUnits)+'-LSTM_u.jpg'\n",
"figRMSEName=confPrefix+'RMSE_Subj'+subjectID+'-'+str(noEpochs)+'pochs-'+orderedPrefix+str(noLSTMUnits)+'-LSTM_u.jpg'\n",
" \n",
"\"\"\" \n",
"list_test=[]\n",
"for i in range(len(test)):\n",
" test[i]=np.transpose(np.array(test[i]))\n",
" list_test.append(test[i])\n",
"\n",
"for j in range(len(test2)): \n",
" test2[j]=np.transpose(np.array(test2[j]))\n",
" list_test.append(test2[j]) \n",
"\n",
" \n",
"print(np.shape(list_test))\n",
"list_test=np.vstack(list_test)\n",
"print(np.shape(list_test))\n",
"scaler = StandardScaler()\n",
"scaler=scaler.fit(list_test)\n",
"scaled_list_test=scaler.transform(list_test)\n",
"print(np.shape(scaled_list_test))\n",
"XT_s_stack=list()\n",
"i=0\n",
"while i+50 <= (len(scaled_list_test)):\n",
" XT_s_stack.append(scaled_list_test[i:i+50])\n",
" i=i+50\n",
"\n",
"\n",
"XT_s_stack=np.stack(XT_s_stack)\n",
"\n",
"cutPoint=np.shape(TTest.reshape(-1))[0]\n",
"\n",
"XTrain_s=XT_s_stack[:-cutPoint,:,:]\n",
"XTest_s=XT_s_stack[-cutPoint:,:,:]\n",
"\n",
"Test=np.transpose(TTest)\n",
"\n",
"print(np.shape(XTrain_s))\n",
"\"\"\""
"figRMSEName=confPrefix+'RMSE_Subj'+subjectID+'-'+str(noEpochs)+'pochs-'+orderedPrefix+str(noLSTMUnits)+'-LSTM_u.jpg'"
]
},
{
"cell_type": "markdown",
"id": "ef14c7b6",
"id": "b4c78ae0",
"metadata": {},
"source": [
"## Call parser function"
Expand All @@ -318,7 +271,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "56a0b4b5",
"id": "3d2a27fe",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -2656,29 +2609,6 @@
"#model.save('1st-stage-subj-1.h5')"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "83113186",
"metadata": {},
"outputs": [],
"source": [
"# print(TTest.shape)\n",
"# print(XTest.shape)\n",
"# print(XTrain.shape)\n",
"# print(TTrain.shape)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "2f475c68",
"metadata": {},
"outputs": [],
"source": [
"# print(TTest)"
]
},
{
"cell_type": "code",
"execution_count": 18,
Expand Down

0 comments on commit 434198e

Please sign in to comment.