To compute Root Mean Squared Error (RMSE) using scikit-learn in Python, you can use the mean_squared_error
function from the sklearn.metrics
module, and then take the square root of the returned value.
Here's an example of how to do it:
main.py257 chars13 lines
In this example, we're using mean_squared_error
to compute the mean squared error between the true values y_true
and predicted values y_pred
. We then take the square root to obtain the RMSE.
The output of this code will be:
main.py25 chars2 lines
Note that mean_squared_error
expects inputs as 1D arrays or lists, so you might need to reshape or flatten your data if it's in a different format.
gistlibby LogSnag