Skip to content

Instantly share code, notes, and snippets.

@firasmdar
Last active February 17, 2019 17:30
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 firasmdar/2d174ecacc1f118a82a2d7c2f5b8ec62 to your computer and use it in GitHub Desktop.
Save firasmdar/2d174ecacc1f118a82a2d7c2f5b8ec62 to your computer and use it in GitHub Desktop.
Simple Linear Regression example using Python & Scikit-Learn
# ai-wd.com
from sklearn import linear_model
ages = [
[18],[20],[22],[25],[27],[31],[34],[35],[37],[39],[42],[44],[50],[55],[61]
]
calories = [
[364.6],[360.0],[346.1],[320.8],[320.4],[322.6],[319.9],[300.1],[288.7],[281.5],[279.2],[267.9],[240.7],[232.0],[211.4]
]
ages_new = [[19],[36],[16],[64]]
Model = linear_model.LinearRegression()
Model.fit(ages,calories)
score = Model.score(ages,calories)
print ("Score:",score)
Model.predict(ages_new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment