@@ -429,13 +429,22 @@ This website_ gives an excellent description on all the variants of errors metri
429
429
430
430
** R- squared** : Percentage of variability of dataset that can be explained by the model.
431
431
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.
433
442
434
- ** RMSE ** : Squared root of MSE so that it gives back the absolute error (as it was initially squared).
435
443
436
444
.. code:: python
437
445
438
446
from sklearn.metrics import mean_squared_error
447
+ from sklearn.metrics import mean_absolute_error
439
448
440
449
forest = RandomForestRegressor(n_estimators = 375 )
441
450
model3 = forest.fit(X_train, y_train)
@@ -461,10 +470,21 @@ This website_ gives an excellent description on all the variants of errors metri
461
470
MSE_test = mean_squared_error(y_test, y_predicted_test)
462
471
463
472
# get RMSE by squared root
464
- print (' \n Total 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 (' \n Total 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
+
467
482
483
+ # Train RMSE: 11.115272389673631
484
+ # Test RMSE: 34.872611746182706
485
+
486
+ # Train MAE 8.067078668023848
487
+ # Train MAE 24.541799999999995
468
488
469
489
470
490
K- fold Cross- Validation
0 commit comments