Skip to content

Instantly share code, notes, and snippets.

@thebigdatajedi
Created May 17, 2022 11:27
Show Gist options
  • Save thebigdatajedi/a50b350b8a09c84cf2ec4c6fff159ff2 to your computer and use it in GitHub Desktop.
Save thebigdatajedi/a50b350b8a09c84cf2ec4c6fff159ff2 to your computer and use it in GitHub Desktop.
#sklearn.metrics has a mean_squared_error function. The RMSE is just the square root of whatever it returns.
#source:https://intellipaat.com/community/1269/is-there-a-library-function-for-root-mean-square-error-rmse-in-python
from sklearn.metrics import mean_squared_error
from math import sqrt
rms = sqrt(mean_squared_error(y_actual, y_predicted))
@thebigdatajedi
Copy link
Author

I was reading how to do this manually without python and then I wondered if I could do it in python.
I did a search with Google, wondering if it was already written for me and it wasn't but mean_squared_error was and all I had is go just one step further instead of composing the calculation myself so I wrote up this gist and documented the source of the code.
I have it in a gist for easy reference and because the answer to the question may get buried by other discussions and answers I explicitly bubbled it up via gist, see source ref in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment