Skip to content

Instantly share code, notes, and snippets.

@gr33ndata
Last active December 11, 2017 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gr33ndata/67843b14175a7a5f0292 to your computer and use it in GitHub Desktop.
Save gr33ndata/67843b14175a7a5f0292 to your computer and use it in GitHub Desktop.
# We are gonna use Scikit's LinearRegression model
from sklearn.linear_model import LinearRegression
# Your input data, X and Y are lists (or Numpy Arrays)
x = [[2,4],[3,6],[4,5],[6,7],[3,3],[2,5],[5,2]]
y = [14,21,22,32,15,16,19]
# Initialize the model then train it on the data
genius_regression_model = LinearRegression()
genius_regression_model.fit(x,y)
# Predict the corresponding value of Y for X = [8,4]
print genius_regression_model.predict([8,4])
@iamosama
Copy link

print (genius_regression_model.predict([[8,4]]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment