Skip to content

Instantly share code, notes, and snippets.

Created December 30, 2017 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/e2907b1b75c54d66792499cb7b5e00b3 to your computer and use it in GitHub Desktop.
Save anonymous/e2907b1b75c54d66792499cb7b5e00b3 to your computer and use it in GitHub Desktop.
from sklearn import linear_model, datasets
#digit dataset from sklearn
digits = datasets.load_digits()
#create the LinearRegression model
clf = linear_model.LinearRegression()
#set training set
x, y = digits.data[:-1], digits.target[:-1]
#train model
clf.fit(x, y)
#predict
y_pred = clf.predict([digits.data[-1]])
y_true = digits.target[-1]
print(y_pred)
print(y_true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment