Skip to content

Commit 96cad65

Browse files
committed
logistic regression
1 parent 4cf90f2 commit 96cad65

2 files changed

Lines changed: 404 additions & 57 deletions

File tree

Lines changed: 38 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 50,
66
"metadata": {},
77
"outputs": [],
88
"source": [
99
"import numpy as np\n",
1010
"import pandas as pd\n",
1111
"from sklearn.cluster import KMeans\n",
12-
"import math\n",
1312
"import csv\n",
1413
"import math\n",
1514
"import matplotlib.pyplot\n",
@@ -19,7 +18,7 @@
1918
},
2019
{
2120
"cell_type": "code",
22-
"execution_count": 2,
21+
"execution_count": 51,
2322
"metadata": {},
2423
"outputs": [],
2524
"source": [
@@ -36,7 +35,7 @@
3635
},
3736
{
3837
"cell_type": "code",
39-
"execution_count": 3,
38+
"execution_count": 52,
4039
"metadata": {},
4140
"outputs": [],
4241
"source": [
@@ -152,7 +151,7 @@
152151
},
153152
{
154153
"cell_type": "code",
155-
"execution_count": 23,
154+
"execution_count": 53,
156155
"metadata": {},
157156
"outputs": [],
158157
"source": [
@@ -210,7 +209,7 @@
210209
},
211210
{
212211
"cell_type": "code",
213-
"execution_count": 24,
212+
"execution_count": 54,
214213
"metadata": {},
215214
"outputs": [],
216215
"source": [
@@ -235,7 +234,7 @@
235234
},
236235
{
237236
"cell_type": "code",
238-
"execution_count": 25,
237+
"execution_count": 55,
239238
"metadata": {},
240239
"outputs": [],
241240
"source": [
@@ -249,6 +248,9 @@
249248
" L_Erms_Val = []\n",
250249
" L_Erms_TR = []\n",
251250
" L_Erms_Test = []\n",
251+
" L_Acc_Val = []\n",
252+
" L_Acc_TR = []\n",
253+
" L_Acc_Test = []\n",
252254
" W_Mat = []\n",
253255
"\n",
254256
" for i in range(0,_loop_range):\n",
@@ -269,22 +271,28 @@
269271
" #-----------------TrainingData Accuracy---------------------#\n",
270272
" TR_TEST_OUT = GetValTest( _TRAINING_PHI, W_T_Next) \n",
271273
" Erms_TR = GetErms(TR_TEST_OUT, _TrainingTarget)\n",
274+
" L_Acc_TR.append(float(Erms_TR.split(',')[0]))\n",
272275
" L_Erms_TR.append(float(Erms_TR.split(',')[1]))\n",
273276
"\n",
274277
" #-----------------ValidationData Accuracy---------------------#\n",
275278
" VAL_TEST_OUT = GetValTest( _VAL_PHI, W_T_Next) \n",
276279
" Erms_Val = GetErms(VAL_TEST_OUT, _ValDataAct)\n",
280+
" L_Acc_Val.append(float(Erms_Val.split(',')[0]))\n",
277281
" L_Erms_Val.append(float(Erms_Val.split(',')[1]))\n",
278282
"\n",
279283
" #-----------------TestingData Accuracy---------------------#\n",
280284
" TEST_OUT = GetValTest( _TEST_PHI, W_T_Next) \n",
281285
" Erms_Test = GetErms(TEST_OUT, _TestDataAct)\n",
286+
" L_Acc_Test.append(float(Erms_Test.split(',')[0]))\n",
282287
" L_Erms_Test.append(float(Erms_Test.split(',')[1]))\n",
283288
" \n",
284289
" print ('----------Gradient Descent Solution--------------------')\n",
285290
" print (\"E_rms Training = \" + str(np.around(min(L_Erms_TR),5)))\n",
286291
" print (\"E_rms Validation = \" + str(np.around(min(L_Erms_Val),5)))\n",
287-
" print (\"E_rms Testing = \" + str(np.around(min(L_Erms_Test),5)))"
292+
" print (\"E_rms Testing = \" + str(np.around(min(L_Erms_Test),5)))\n",
293+
" print (\"Accuracy Training = \" + str(np.around(max(L_Acc_TR),5)))\n",
294+
" print (\"Accuracy Validation = \" + str(np.around(max(L_Acc_Val),5)))\n",
295+
" print (\"Accuracy Testing = \" + str(np.around(max(L_Acc_Test),5)))"
288296
]
289297
},
290298
{
@@ -296,7 +304,7 @@
296304
},
297305
{
298306
"cell_type": "code",
299-
"execution_count": 26,
307+
"execution_count": 56,
300308
"metadata": {},
301309
"outputs": [],
302310
"source": [
@@ -308,7 +316,7 @@
308316
},
309317
{
310318
"cell_type": "code",
311-
"execution_count": 27,
319+
"execution_count": 57,
312320
"metadata": {},
313321
"outputs": [],
314322
"source": [
@@ -333,7 +341,7 @@
333341
},
334342
{
335343
"cell_type": "code",
336-
"execution_count": 28,
344+
"execution_count": 58,
337345
"metadata": {},
338346
"outputs": [
339347
{
@@ -356,9 +364,12 @@
356364
"Testing Phi: (157, 5)\n",
357365
"Validation Phi: (158, 5)\n",
358366
"----------Gradient Descent Solution--------------------\n",
359-
"E_rms Training = 0.49933\n",
360-
"E_rms Validation = 0.49939\n",
361-
"E_rms Testing = 0.47696\n"
367+
"E_rms Training = 0.49923\n",
368+
"E_rms Validation = 0.49557\n",
369+
"E_rms Testing = 0.4937\n",
370+
"Accuracy Training = 54.58136\n",
371+
"Accuracy Validation = 56.96203\n",
372+
"Accuracy Testing = 59.87261\n"
362373
]
363374
}
364375
],
@@ -378,7 +389,7 @@
378389
},
379390
{
380391
"cell_type": "code",
381-
"execution_count": 29,
392+
"execution_count": 59,
382393
"metadata": {},
383394
"outputs": [
384395
{
@@ -401,9 +412,12 @@
401412
"Testing Phi: (157, 5)\n",
402413
"Validation Phi: (158, 5)\n",
403414
"----------Gradient Descent Solution--------------------\n",
404-
"E_rms Training = 0.49949\n",
405-
"E_rms Validation = 0.49925\n",
406-
"E_rms Testing = 0.47915\n"
415+
"E_rms Training = 0.49978\n",
416+
"E_rms Validation = 0.49704\n",
417+
"E_rms Testing = 0.49491\n",
418+
"Accuracy Training = 51.73776\n",
419+
"Accuracy Validation = 55.6962\n",
420+
"Accuracy Testing = 57.96178\n"
407421
]
408422
}
409423
],
@@ -427,7 +441,7 @@
427441
},
428442
{
429443
"cell_type": "code",
430-
"execution_count": 30,
444+
"execution_count": 60,
431445
"metadata": {},
432446
"outputs": [],
433447
"source": [
@@ -439,7 +453,7 @@
439453
},
440454
{
441455
"cell_type": "code",
442-
"execution_count": 31,
456+
"execution_count": 73,
443457
"metadata": {},
444458
"outputs": [],
445459
"source": [
@@ -462,7 +476,7 @@
462476
},
463477
{
464478
"cell_type": "code",
465-
"execution_count": 18,
479+
"execution_count": null,
466480
"metadata": {},
467481
"outputs": [
468482
{
@@ -480,14 +494,7 @@
480494
"Validation Data: (1017, 14306)\n",
481495
"Testing Target: (14305,)\n",
482496
"Testing Data: (1017, 14305)\n",
483-
"BigSigma: (1017, 1017)\n",
484-
"Training Phi: (114450, 5)\n",
485-
"Testing Phi: (14305, 5)\n",
486-
"Validation Phi: (14306, 5)\n",
487-
"----------Gradient Descent Solution--------------------\n",
488-
"E_rms Training = 0.54717\n",
489-
"E_rms Validation = 0.55033\n",
490-
"E_rms Testing = 0.55555\n"
497+
"BigSigma: (1017, 1017)\n"
491498
]
492499
}
493500
],
@@ -508,35 +515,9 @@
508515
},
509516
{
510517
"cell_type": "code",
511-
"execution_count": 32,
518+
"execution_count": null,
512519
"metadata": {},
513-
"outputs": [
514-
{
515-
"name": "stdout",
516-
"output_type": "stream",
517-
"text": [
518-
"=========================\n",
519-
"====== GSC Data =========\n",
520-
"==== Subtraction ======\n",
521-
"=========================\n",
522-
"RawData : (509, 143062)\n",
523-
"Training Target: (114450,)\n",
524-
"Training Data: (509, 114450)\n",
525-
"Validation Target: (14306,)\n",
526-
"Validation Data: (509, 14306)\n",
527-
"Testing Target: (14305,)\n",
528-
"Testing Data: (509, 14305)\n",
529-
"BigSigma: (509, 509)\n",
530-
"Training Phi: (114450, 5)\n",
531-
"Testing Phi: (14305, 5)\n",
532-
"Validation Phi: (14306, 5)\n",
533-
"----------Gradient Descent Solution--------------------\n",
534-
"E_rms Training = 0.52324\n",
535-
"E_rms Validation = 0.5284\n",
536-
"E_rms Testing = 0.52343\n"
537-
]
538-
}
539-
],
520+
"outputs": [],
540521
"source": [
541522
"# Now we are merging the image specifications with the dataset, we will use this dataset to train\n",
542523
"# test or validate data.\n",

0 commit comments

Comments
 (0)