Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.