March 2020
Beginner to intermediate
352 pages
8h 40m
English
Sklearn provides metrics that help us evaluate our models with multiple formulas. The three main metrics used to evaluate models are mean absolute error, mean squared error, and R2score.
Let's quickly try these methods:
# Scoring the modelfrom sklearn.metrics import r2_score, mean_squared_error,mean_absolute_error# R2 Scoreprint(f"R2 score: {r2_score(y_test, y_pred)}")# Mean Absolute Error (MAE)print(f"MSE score: {mean_absolute_error(y_test, y_pred)}")# Mean Squared Error (MSE)print(f"MSE score: {mean_squared_error(y_test, y_pred)}")
The output of the preceding code is as follows:
R2 score: 0.5383003344910231MSE score: 4.750294229575126MSE score: 45.0773394247183
Note that we are not evaluating the accuracies we got in ...
Read now
Unlock full access