Skip to content

Instantly share code, notes, and snippets.

@sharathgrao
Created July 1, 2020 17:48
Show Gist options
  • Save sharathgrao/f39f6af66ffa37f733dc442dd0979ed1 to your computer and use it in GitHub Desktop.
Save sharathgrao/f39f6af66ffa37f733dc442dd0979ed1 to your computer and use it in GitHub Desktop.
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