0% found this document useful (0 votes)
14 views3 pages

Logistic Regression Worksheet Solution

The document presents a dataset containing body mass index, age, exercise levels, and diabetes outcomes, along with normalized data and iterative calculations for a predictive model. It details multiple iterations of weight updates and confusion matrices, showing the accuracy of the model in predicting diabetes. The final weights after several iterations indicate the model's adjustments based on the training data.

Uploaded by

me22b016
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

Logistic Regression Worksheet Solution

The document presents a dataset containing body mass index, age, exercise levels, and diabetes outcomes, along with normalized data and iterative calculations for a predictive model. It details multiple iterations of weight updates and confusion matrices, showing the accuracy of the model in predicting diabetes. The final weights after several iterations indicate the model's adjustments based on the training data.

Uploaded by

me22b016
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Given data

Body Mass Outcome


Sl. No. Age (x 2 ) Exercise (x 3 )
Index (x 1 ) (Diabetic or not)
1 32.32 46 0 1
2 18.3 64 2 0 Feature Max Min
3 30.53 51 2 1 x1 32.32 12.04
4 12.04 55 2 0 x2 79 45
5 12.69 59 2 0 x3 3 0
6 24.88 79 2 1
7 23.25 69 0 1
8 20.47 45 3 0
9 18.39 73 1 1
10 25.56 69 1 1

Normalized data

Sl. No. x 1+ x 2+ x 3+ y
1 1.0000 0.0294 0.0000 1
2 0.3087 0.5588 0.6667 0
3 0.9117 0.1765 0.6667 1
4 0.0000 0.2941 0.6667 0
5 0.0321 0.4118 0.6667 0
6 0.6331 1.0000 0.6667 1
7 0.5528 0.7059 0.0000 1
8 0.4157 0.0000 1.0000 0
9 0.3131 0.8235 0.3333 1
10 0.6667 0.7059 0.3333 1
Iteration 1
w0 = 0.5 w1 = 2 w2 = 1 w3 = -2 α = 1.5

Sl. No. x 1+ x 2+ x 3+ y z g(z) yfit hw(x) (y-hw(x)) (y-hw(x))*x 1+ (y-hw(x))*x 2+ (y-hw(x))*x 3+ TP FP FN TN


1 1.0000 0.0294 0.0000 1 2.5294 0.9262 1 0.9262 0.0738 0.0738 0.0022 0 1 0 0 0
2 0.3087 0.5588 0.6667 0 0.3428 0.5849 1 0.5849 -0.5849 -0.1805 -0.3268 -0.3899 0 1 0 0
3 0.9117 0.1765 0.6667 1 1.1666 0.7625 1 0.7625 0.2375 0.2165 0.0419 0.1583 1 0 0 0
4 0.0000 0.2941 0.6667 0 -0.5392 0.3684 0 0.3684 -0.3684 0.0000 -0.1083 -0.2456 0 0 0 1
5 0.0321 0.4118 0.6667 0 -0.3575 0.4116 0 0.4116 -0.4116 -0.0132 -0.1695 -0.2744 0 0 0 1
6 0.6331 1.0000 0.6667 1 1.4329 0.8074 1 0.8074 0.1926 0.1220 0.1926 0.1284 1 0 0 0
7 0.5528 0.7059 0.0000 1 2.3114 0.9098 1 0.9098 0.0902 0.0498 0.0637 0.0000 1 0 0 0
8 0.4157 0.0000 1.0000 0 -0.6686 0.3388 0 0.3388 -0.3388 -0.1408 0.0000 -0.3388 0 0 0 1
9 0.3131 0.8235 0.3333 1 1.2831 0.7830 1 0.7830 0.2170 0.0680 0.1787 0.0723 1 0 0 0
10 0.6667 0.7059 0.3333 1 1.8725 0.8668 1 0.8668 0.1332 0.0888 0.0941 0.0444 1 0 0 0
Σ -0.7592 0.2844 -0.0315 -0.8452 6 1 0 3

Confusion matrix Accuracy = 0.9 Updated weights


6 1 w0 0.3861
0 3 w1 2.0427
w2 0.9953
w3 -2.1268

Iteration 2
w0 = 0.3861 w1 = 2.0427 w2 = 0.9953 w3 = -2.1268 α = 1.5

Sl. No. x 1+ x 2+ x 3+ y z g(z) yfit hw(x) (y-hw(x)) (y-hw(x))*x 1+ (y-hw(x))*x 2+ (y-hw(x))*x 3+ TP FP FN TN


1 1.0000 0.0294 0.0000 1 2.4580 0.9211 1 0.9211 0.0789 0.0789 0.0023 0 1 0 0 0
2 0.3087 0.5588 0.6667 0 0.1550 0.5387 1 0.5387 -0.5387 -0.1663 -0.3010 -0.3591 0 1 0 0
3 0.9117 0.1765 0.6667 1 1.0063 0.7323 1 0.7323 0.2677 0.2441 0.0472 0.1785 1 0 0 0
4 0.0000 0.2941 0.6667 0 -0.7390 0.3232 0 0.3232 -0.3232 0.0000 -0.0951 -0.2155 0 0 0 1
5 0.0321 0.4118 0.6667 0 -0.5564 0.3644 0 0.3644 -0.3644 -0.0117 -0.1500 -0.2429 0 0 0 1
6 0.6331 1.0000 0.6667 1 1.2568 0.7785 1 0.7785 0.2215 0.1403 0.2215 0.1477 1 0 0 0
7 0.5528 0.7059 0.0000 1 2.2178 0.9018 1 0.9018 0.0982 0.0543 0.0693 0.0000 1 0 0 0
8 0.4157 0.0000 1.0000 0 -0.8916 0.2908 0 0.2908 -0.2908 -0.1209 0.0000 -0.2908 0 0 0 1
9 0.3131 0.8235 0.3333 1 1.1364 0.7570 1 0.7570 0.2430 0.0761 0.2001 0.0810 1 0 0 0
10 0.6667 0.7059 0.3333 1 1.7415 0.8509 1 0.8509 0.1491 0.0994 0.1053 0.0497 1 0 0 0
Σ -0.4587 0.3941 0.0996 -0.6514 6 1 0 3

Confusion matrix Accuracy = 0.9 Updated weights


6 1 w0 0.3173
0 3 w1 2.1018
w2 1.0102
w3 -2.2245
Iteration 3
w0 = 0.3173 w1 = 2.1018 w2 = 1.0102 w3 = -2.2245 α = 1.5

Sl. No. x 1+ x 2+ x 3+ y z g(z) yfit hw(x) (y-hw(x)) (y-hw(x))*x 1+ (y-hw(x))*x 2+ (y-hw(x))*x 3+ TP FP FN TN


1 1.0000 0.0294 0.0000 1 2.4488 0.9205 1 0.9205 0.0795 0.0795 0.0023 0 1 0 0 0
2 0.3087 0.5588 0.6667 0 0.0476 0.5119 1 0.5119 -0.5119 -0.1580 -0.2861 -0.3413 0 1 0 0
3 0.9117 0.1765 0.6667 1 0.9289 0.7168 1 0.7168 0.2832 0.2582 0.0500 0.1888 1 0 0 0
4 0.0000 0.2941 0.6667 0 -0.8686 0.2956 0 0.2956 -0.2956 0.0000 -0.0869 -0.1970 0 0 0 1
5 0.0321 0.4118 0.6667 0 -0.6823 0.3357 0 0.3357 -0.3357 -0.0108 -0.1382 -0.2238 0 0 0 1
6 0.6331 1.0000 0.6667 1 1.1752 0.7641 1 0.7641 0.2359 0.1494 0.2359 0.1573 1 0 0 0
7 0.5528 0.7059 0.0000 1 2.1922 0.8995 1 0.8995 0.1005 0.0555 0.0709 0.0000 1 0 0 0
8 0.4157 0.0000 1.0000 0 -1.0335 0.2624 0 0.2624 -0.2624 -0.1091 0.0000 -0.2624 0 0 0 1
9 0.3131 0.8235 0.3333 1 1.0659 0.7438 1 0.7438 0.2562 0.0802 0.2110 0.0854 1 0 0 0
10 0.6667 0.7059 0.3333 1 1.6901 0.8442 1 0.8442 0.1558 0.1038 0.1100 0.0519 1 0 0 0
Σ -0.2946 0.4488 0.1688 -0.5412 6 1 0 3

Confusion matrix Accuracy = 0.9 Updated weights


6 1 w0 0.2731
0 3 w1 2.1691
w2 1.0355
w3 -2.3057

Iteration 4
w0 = 0.2731 w1 = 2.1691 w2 = 1.0355 w3 = -2.3057 α = 1.5

Sl. No. x 1+ x 2+ x 3+ y z g(z) yfit hw(x) (y-hw(x)) (y-hw(x))*x 1+ (y-hw(x))*x 2+ (y-hw(x))*x 3+ TP FP FN TN


1 1.0000 0.0294 0.0000 1 2.4727 0.9222 1 0.9222 0.0778 0.0778 0.0023 0 1 0 0 0
2 0.3087 0.5588 0.6667 0 -0.0158 0.4961 0 0.4961 -0.4961 -0.1531 -0.2772 -0.3307 0 0 0 1
3 0.9117 0.1765 0.6667 1 0.8964 0.7102 1 0.7102 0.2898 0.2642 0.0511 0.1932 1 0 0 0
4 0.0000 0.2941 0.6667 0 -0.9594 0.2770 0 0.2770 -0.2770 0.0000 -0.0815 -0.1847 0 0 0 1
5 0.0321 0.4118 0.6667 0 -0.7681 0.3169 0 0.3169 -0.3169 -0.0102 -0.1305 -0.2113 0 0 0 1
6 0.6331 1.0000 0.6667 1 1.1449 0.7586 1 0.7586 0.2414 0.1529 0.2414 0.1610 1 0 0 0
7 0.5528 0.7059 0.0000 1 2.2031 0.9005 1 0.9005 0.0995 0.0550 0.0702 0.0000 1 0 0 0
8 0.4157 0.0000 1.0000 0 -1.1309 0.2440 0 0.2440 -0.2440 -0.1014 0.0000 -0.2440 0 0 0 1
9 0.3131 0.8235 0.3333 1 1.0365 0.7382 1 0.7382 0.2618 0.0820 0.2156 0.0873 1 0 0 0
10 0.6667 0.7059 0.3333 1 1.6816 0.8431 1 0.8431 0.1569 0.1046 0.1107 0.0523 1 0 0 0
Σ -0.2068 0.4717 0.2023 -0.4769 6 0 0 4

Confusion matrix Accuracy = 1 Updated weights


6 0 w0 0.2421
0 4 w1 2.2398
w2 1.0659
w3 -2.3772
\

You might also like