from sklearn.linear_model import LinearRegression
import numpy as np
import matplotlib.pyplot as plt
x = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
y = np.array([1, 3, 2, 5, 7, 8, 8, 9, 10, 12])
lreg=LinearRegression()
lreg.fit(x.reshape(-1, 1), y)
plt.scatter(x, y)
plt.plot(x, lreg.predict(x.reshape(-1, 1)), color='red')
plt.title("Linear Regression")
plt.xlabel("x")
plt.ylabel("y")
plt.show()