Skip to content

Instantly share code, notes, and snippets.

@nithyadurai87
Last active September 26, 2018 06:46
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 nithyadurai87/7068c32bd4d7fccb67ccca39623f68bc to your computer and use it in GitHub Desktop.
Save nithyadurai87/7068c32bd4d7fccb67ccca39623f68bc to your computer and use it in GitHub Desktop.
from sklearn.linear_model import LinearRegression
from numpy.linalg import lstsq
import numpy as np
x = [[6, 2], [8, 1], [10, 0], [14, 2], [18, 0]]
y = [[7], [9], [13], [17.5], [18]]
model = LinearRegression()
model.fit(x,y)
x1 = [[8, 2], [9, 0], [11, 2], [16, 2], [12, 0]]
y1 = [[11], [8.5], [15], [18], [11]]
predictions = model.predict([[8, 2], [9, 0], [12, 0]])
print ("values of Predictions: ",predictions)
print ("values of β1, β2: ",lstsq(x, y, rcond=None)[0])
print ("Score = ",model.score(x1, y1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment