Running your framework code on Amazon SageMaker
We will start from a vanilla scikit-learn program that trains and saves a linear regression model on the Boston Housing dataset, which we used in Chapter 4, Training Machine Learning Models:
import pandas as pd from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error, r2_score import joblib data = pd.read_csv('housing.csv') labels = data[['medv']] samples = data.drop(['medv'], axis=1) X_train, X_test, y_train, y_test = train_test_split( samples, labels, test_size=0.1, random_state=123) regr = LinearRegression(normalize=True) regr.fit(X_train, y_train) y_pred = regr.predict(X_test) print('Mean squared error: %.2f' % mean_squared_error(y_test, y_pred)) print('Coefficient of determination: %.2f' % r2_score(y_test, y_pred...