Last active
May 21, 2018 03:08
-
-
Save b00033811/aec894e45a01971fba32d4fdf54e1940 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 sklearn.model_selection import train_test_split | |
model=LinearRegression() | |
y=y.reshape(-1,1) # reshaping the data | |
x=x.reshape(-1,1) | |
#spliting into test/train with a test size of .3 or 30 samples. | |
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.3,shuffle=True) | |
model.fit(x_train,y_train) # fitting the model | |
print(model.score(x_test,y_test)) # get the r2 score | |
p=model.predict(x) # generate a prediction from the model using the original input | |
plt.plot(x,p,c='b',label='prediction') | |
plt.legend() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment