November 2017
Intermediate to advanced
374 pages
10h 19m
English
from sklearn.linear_model import LinearRegression, TheilSenRegressorfrom sklearn.metrics import r2_score, mean_absolute_errornamed_estimators = [('OLS ', LinearRegression()), ('TSR ', TheilSenRegressor())]for num_index, est in enumerate(named_estimators): y_pred = est[1].fit(x_vals.reshape(-1, 1),y_noisy).predict(x_vals.reshape(-1, 1)) print (est[0], "R-squared: ", r2_score(y_truth, y_pred), "Mean Absolute Error", mean_absolute_error(y_truth, y_pred)) plt.plot(x_vals, y_pred, label=est[0])('OLS ', 'R-squared: ', 0.17285546630270587, 'Mean Absolute Error', 44.099173357335729) ('TSR ', 'R-squared: ', ...Read now
Unlock full access