Skip to content

Instantly share code, notes, and snippets.

@IceCereal
Created March 6, 2019 12:28
Show Gist options
  • Save IceCereal/d0b77ed9f4d515248f2bb31155d01d0b to your computer and use it in GitHub Desktop.
Save IceCereal/d0b77ed9f4d515248f2bb31155d01d0b to your computer and use it in GitHub Desktop.
LinReg
from sklearn import linear_model
from matplotlib import pyplot as plt
x = [[2],[1],[5],[10]]
y = [27, 11, 75, 155]
LinearRegression = linear_model.LinearRegression()
LinearRegression = LinearRegression.fit(x,y)
plt.scatter(x,y)
plt.show()
predicted = LinearRegression.predict([[8]])
plt.scatter(x,y)
plt.scatter(8, predicted, c='red')
plt.show()
print(predicted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment