Is there a library function for Root mean square error (RMSE) in python?

2.1K    Asked by ChristianParsons in Python , Asked on Mar 7, 2021

 I know I could implement a root mean squared error function like this:

def rmse(predictions, targets):
return np.sqrt(((predictions - targets) ** 2).mean())

What I'm looking for if this rmse function is implemented in a library somewhere, perhaps in scipy or scikit-learn?

Root mean squared error (RMSE): RMSE (Sklearn RMSE) is a quadratic scoring rule that also measures the average magnitude of the error. It’s the square root of the average squared differences between prediction and actual observation.


In the scikit learn library, sklearn.metrics has a mean_squared_error function. The Sklearn RMSE is just the square root of values it returns.

For example:

from sklearn.metrics import mean_squared_error

from math import sqrt

rmse = sqrt(mean_squared_error(y_actual, y_predicted))

print(rmse)



Your Answer

Interviews

Parent Categories