Created
July 1, 2020 17:48
-
-
Save sharathgrao/f39f6af66ffa37f733dc442dd0979ed1 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.metrics import median_absolute_error, r2_score | |
from sklearn.model_selection import train_test_split | |
from sklearn.datasets import load_boston | |
boston = load_boston() | |
X_train, X_test, y_train, y_test = train_test_split(boston.data, boston.target, random_state=1) | |
regr = LinearRegression() | |
regr.fit(X_train, y_train) | |
y_pred = regr.predict(X_test) | |
print(r2_score(y_test, y_pred)) | |
print(median_absolute_error(y_test, y_pred)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment