+1 vote
in Programming Languages by (59.8k points)
I want to compute RMSE using true values and predicted values. Is there any Python function for RMSE?

1 Answer

+1 vote
by (353k points)
 
Best answer

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

  1. Calculate the element-wise difference between the true and predicted array of values.
  2. Calculate the square of each difference and then sum them.
  3. Divide the sum by the number of elements in the true/predicted array.
  4. 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

...