Skip to content

Commit 3455047

Browse files
author
“jake”
committed
.
1 parent da396f3 commit 3455047

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

evaluation.rst

+25-5
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,22 @@ This website_ gives an excellent description on all the variants of errors metri
429429
430430
**R-squared**: Percentage of variability of dataset that can be explained by the model.
431431
432-
**MSE**. Mean squared error. Mean squaring of all absolute error (so change negatives into positives).
432+
**MSE**. Mean squared error. Squaring then getting the mean of all errors (so change negatives into positives).
433+
434+
**RMSE**: Squared root of MSE so that it gives back the error at the same scale (as it was initially squared).
435+
436+
**MAE**: Mean Absolute Error. For negative errors, convert them to positive and obtain all error means.
437+
438+
439+
The RMSE result will always be larger or equal to the MAE. If all of the errors have the same magnitude, then RMSE=MAE.
440+
Since the errors are squared before they are averaged, the RMSE gives a relatively high weight to large errors.
441+
This means the RMSE should be more useful when large errors are particularly undesirable.
433442
434-
**RMSE**: Squared root of MSE so that it gives back the absolute error (as it was initially squared).
435443
436444
.. code:: python
437445
438446
from sklearn.metrics import mean_squared_error
447+
from sklearn.metrics import mean_absolute_error
439448
440449
forest = RandomForestRegressor(n_estimators= 375)
441450
model3 = forest.fit(X_train, y_train)
@@ -461,10 +470,21 @@ This website_ gives an excellent description on all the variants of errors metri
461470
MSE_test = mean_squared_error(y_test, y_predicted_test)
462471
463472
# get RMSE by squared root
464-
print('\nTotal RMSE:', format(np.sqrt(MSE_total), 'e'))
465-
print('Train RMSE:', format(np.sqrt(MSE_train), 'e'))
466-
print('Test RMSE:', format(np.sqrt(MSE_test), 'e'))
473+
print('\nTotal RMSE:', np.sqrt(MSE_total))
474+
print('Train RMSE:', np.sqrt(MSE_train))
475+
print('Test RMSE:', np.sqrt(MSE_test))
476+
477+
# get MAE
478+
MAE_total = mean_absolute_error(target, y_predicted_total)
479+
MAE_train = mean_absolute_error(y_train, y_predicted_train)
480+
MAE_test = mean_absolute_error(y_test, y_predicted_test)
481+
467482
483+
# Train RMSE: 11.115272389673631
484+
# Test RMSE: 34.872611746182706
485+
486+
# Train MAE 8.067078668023848
487+
# Train MAE 24.541799999999995
468488
469489
470490
K-fold Cross-Validation

supervised.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ Same as randomforest classifier but the target is continuous.
12511251

12521252
.. code:: python
12531253
1254-
from sklearn.tree import RandomForestRegressor
1254+
from sklearn.ensemble import RandomForestRegressor
12551255
12561256
12571257
Neutral Networks

0 commit comments

Comments
 (0)