Skip to content

Difference in rmse values #19582

Answered by i-aki-y
sheecegardezi asked this question in Q&A
Feb 28, 2021 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

RMSE is the "square root of mean square errors".
However, your implementation calculates the "mean of square root of square errors".
These are mathematically different.
You can write like np.sqrt(np.average(np.square(np.subtract(y_oos, y_pred)))).

from sklearn.metrics import mean_squared_error

def fix_custom_rmse_function(y_pred, y_oos):
    return np.sqrt(np.average(np.square(np.subtract(y_oos, y_pred))))

y_oos = [0.58, 0.55, 0.48, 0.52, 0.62]
y_pred = [0.60, 0.59, 0.57, 0.60, 0.57]

print(fix_custom_rmse_function(y_oos, y_pred ))
print(np.sqrt(mean_squared_error(y_oos, y_pred)))
> 0.061644140029689744
> 0.061644140029689744

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@sheecegardezi
Comment options

@lesteve
Comment options

Answer selected by sheecegardezi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants