{"id":1037,"hash":"6cafdc45598d2bc8e6f003c6c8bdd6f8ff40128f47d3b60e22cb6cae3d3ca527","pattern":"Is there a library function for Root mean square error (RMSE) in python?","full_message":"I know I could implement a root mean squared error function like this:\n\ndef rmse(predictions, targets):\n    return np.sqrt(((predictions - targets) ** 2).mean())\n\nWhat I'm looking for if this rmse function is implemented in a library somewhere, perhaps in scipy or scikit-learn?","ecosystem":"pypi","package_name":"scikit-learn","package_version":null,"solution":"sklearn >= 1.4\n\nsklearn.metrics.root_mean_squared_error\n\nfrom sklearn.metrics import root_mean_squared_error\n\nrms = root_mean_squared_error(y_actual, y_predicted)\n\nsklearn >= 0.22.0 and < 1.4\n\nsklearn.metrics has a mean_squared_error function with a squared kwarg (defaults to True). Setting squared to False will return the RMSE.\n\nfrom sklearn.metrics import mean_squared_error\n\nrms = mean_squared_error(y_actual, y_predicted, squared=False)","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/17197492/is-there-a-library-function-for-root-mean-square-error-rmse-in-python","votes":275,"created_at":"2026-04-19T04:52:13.796347+00:00","updated_at":"2026-04-19T04:52:16.865881+00:00"}