Last active
February 17, 2019 17:30
-
-
Save firasmdar/2d174ecacc1f118a82a2d7c2f5b8ec62 to your computer and use it in GitHub Desktop.
Simple Linear Regression example using Python & Scikit-Learn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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