Root mean squared error (RMSE) is a popular evaluation metric to evaluate regression models in the data science field. It is often used to measure the difference between predicted and actual values of a target variable. To calculate RMSE, following steps can be taken:
Here is the Python code to implement the RMSE calculation from scratch:
main.py296 chars12 lines
In the above code, y_true
is the actual value of response variable and y_pred
is predicted value. You can verify the implementation by comparing your result with the in-built mean_squared_error
function from sklearn.metrics
library.
main.py245 chars10 lines
Output:
main.py38 chars3 lines
Both the implemented function and the mean_squared_error
function from sklearn's library result in the same output for the above example.
gistlibby LogSnag