Linear Regression
Linear Regression
input
Prediction is different from classification
Classification refers to predict categorical class label
1
Linear regression analysis
| D|
(x x )( yi y )
w
i
i 1
1 | D|
(x i x )2
i 1
w y w x
0 1
3
Linear Regression using least square method example
4
Numerical example
Linear Regression using least square method example | D|
(x x )( yi y )
w
i
Step2 Step3 Step 4 Step 5 i 1
(x i x )2
72 84 0.17- 10 1.7- 0.0289 i 1
50 63 22.17- 11- 243.87 491.5089
81 77 8.83 3 26.49 77.9689
74 78 1.83 4 7.32 3.3489
94 90 21.83 16 349.28 476.5489
86 75 13.83 1 13.83 191.2689 W1= 2004 /3445.67
59 49 13.17- 25- 329.25 173.4489
83 79 10.83 5 54.15 117.2889
65 77 7.17- 3 21.51- 51.4089 =0.5816
33 52 39.17- 22- 861.74 1534.2889
88 74 15.83 0 0 250.5889
81 90 8.83 16 141.28 77.9689
sum sum
w y w x
average x
72.17
Average y
74
2004 3445.67 0 1
W0= 74 – 0.5816 * 72.17
y = w0 + w1 x
=32.02
Y=32.02+0.5816 x
So, when the mid exam is 86, the predicated value of the final exam will be 82.04
5
Regression accuracy metrics
MAE (Mean absolute error) represents the difference between the original and predicted values
extracted by averaged the absolute difference over the data set.
72 84 73.8952 10.1048
50 63 61.1 1.9
81 77 79.1296 2.1296
74 78 75.0584 2.9416
94 90 86.6904 3.3096
86 75 82.0376 7.0376
59 49 66.3344 17.3344
83 79 80.2928 1.2928
65 77 69.824 7.176
33 52 51.2128 0.7872
88 74 83.2008 9.2008
81 90 79.1296 10.8704
ERORR = 6.173733333