Mean squared error and root mean squared error

Mean squared error (MSE) is a widely used metric for regression algorithms to estimate their quality. It is an average squared difference between the predictions and ground truth values. This is given by the following equation:

Here,   is the number of predictions and ground truth items,  is the ground truth value for the ith item, and  is the prediction value for the ith item.

MSE is often used as a target loss function for optimization algorithms because it is smoothly differentiable and is a convex function.

The root mean squared error (RMSE) metric is usually used to estimate performance, such as when we need to give bigger weights to higher errors (to penalize them). We can interpret this as the standard deviation of the differences between predictions and ground truth values. This is given by the following equation:

The following sample shows an MSE calculation being performed with the Shark-ML library:

SquaredLoss<> mse_loss;
auto mse = mse_loss(train_data.labels(), predictions);
auto rmse = std::sqrt(mse);

In this example, we calculated the MSE value by using the SquaredLoss type object. Objects of the SquaredLoss type can be used functional objects, and they take the training labels (ground truth values) values and prediction values as arguments. The calculation result is a floating-point value. Notice that to get the RMSE value, we just take the square root of the result value.

The following example shows an MSE calculation being performed with the Shogun library:

auto mse_error = some<CMeanSquaredError>();
auto mse = mse_error->evaluate(predictions, train_labels);

In this example, we calculated the MSE value using the CMeanSquareError type object. The evaluate method takes the prediction values and training labels (ground truth values) as arguments and returns the floating-point value as the result.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.123.73