Machine Learning Lab: Raheel Aslam (74-FET/BSEE/F16)
Machine Learning Lab: Raheel Aslam (74-FET/BSEE/F16)
Machine Learning Lab: Raheel Aslam (74-FET/BSEE/F16)
return(b_0, b_1)
# putting labels
plt.xlabel('x')
plt.ylabel('y')
# estimating coefficients
b = estimate_coef(x, y)
print("Estimated coefficients:\nb_0 = {} \ \nb_1 = {}".format(b[0], b[1]))
Output:
Estimated coefficients:
b_0 = 1.2363636363636363 \
b_1 = 1.1696969696969697
# regression coefficients
print('Coefficients: \n', reg.coef_)
## plotting legend
plt.legend(loc = 'upper right')
## plot title
plt.title("Residual errors")
Output:
Coefficients:
[-1.14428903e-01 5.71299780e-02 3.83002824e-02 2.42854641e+00
-2.12326236e+01 2.87723416e+00 6.91118094e-03 -1.47158266e+00
3.05784197e-01 -1.06750361e-02 -9.96138270e-01 6.27746234e-03
-5.57414427e-01]
Variance score: 0.7789410172622865