Last active
September 26, 2018 06:46
-
-
Save nithyadurai87/7068c32bd4d7fccb67ccca39623f68bc to your computer and use it in GitHub Desktop.
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
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