I want to compute RMSE using true values and predicted values. Is there any Python function for RMSE?

+1 vote

Best answer

To calculate the RMSE, you need to follow these steps:

- Calculate the element-wise difference between the true and predicted array of values.
- Calculate the square of each difference and then sum them.
- Divide the sum by the number of elements in the true/predicted array.
- Take the square root of the value calculated in step 3.

Here is an example:

>>> import numpy as np

>>> tru = np.asarray([1,2,3,4,5])

>>> preds = np.asarray([11,12,13,14,15])>>> rmse = np.sqrt(np.sum(np.square(tru - preds))/np.size(tru))

>>> rmse

10.0