Professional Documents
Culture Documents
Experiment No. 1
Student Name: Deepak Kumar Mondal UID: 21MCA2263
Section/Group: 21MCA4-B Semester: 3rd
Date of Submission: 02-09-2022
Linear Regression
Task To Be Done
Write a Program to implement Linear Regression
import numpy as np
import matplotlib.pyplot as plt
m_x = np.mean(x)
m_y = np.mean(y)
plt.xlabel('x')
plt.ylabel('y')
plt.show()
def main():
x = np.array([0, 1, 2, 4, 6, 10, 14, 21])
y = np.array([1, 2, 4, 8, 12, 20, 28, 42])
b = estimate_coef(x, y)
print("Estimated coefficients:\nb_0 = {} \
\nb_1 = {}".format(b[0], b[1]))
plot_regression_line(x, y, b)
if __name__ == "__main__":
main()
Result/Output
Learning outcomes (What I have learned)
Evaluation Grid: