📅  最后修改于: 2023-12-03 15:34:43.815000             🧑  作者: Mango
Root Mean Square Error (RMSE) is a commonly used metric to evaluate the performance of regression models. It measures the difference between predicted values and actual values of a model. In MATLAB, calculating RMSE is easy and can be done using built-in functions.
The syntax for calculating RMSE in MATLAB is as follows:
rmse = sqrt(mean((predicted - actual).^2))
where:
predicted
: vector or matrix containing predicted valuesactual
: vector or matrix containing actual valuesrmse
: scalar value of the root mean square errorHere's an example of how to calculate RMSE in MATLAB:
% Generate random data
predicted = rand(1,10);
actual = rand(1,10);
% Calculate RMSE
rmse = sqrt(mean((predicted - actual).^2));
fprintf('RMSE: %f\n', rmse);
Output:
RMSE: 0.296098
In conclusion, RMSE is a useful metric to evaluate the accuracy of regression models. In MATLAB, it can be easily calculated using the sqrt
and mean
functions.