Implementation of Simple Linear Regression in Python
Implementation of Simple Linear Regression in Python
import numpy as np
Y = np.array([2, 4, 5, 4, 5])
model = LinearRegression()
model.fit(X, Y)
# Prediction
Y_pred = model.predict(X)
# Evaluation
print("Intercept:", model.intercept_)
# Plotting
plt.xlabel('X')
plt.ylabel('Y')
plt.legend()
plt.show()