Skip to content

Instantly share code, notes, and snippets.

@AayushSameerShah
Last active April 18, 2024 04:38
Show Gist options
  • Save AayushSameerShah/baeedbbb52fe808874d6debb7e786183 to your computer and use it in GitHub Desktop.
Save AayushSameerShah/baeedbbb52fe808874d6debb7e786183 to your computer and use it in GitHub Desktop.
Relative Root Mean Squared Error (RRMSE)
def relative_root_mean_squared_error(true, pred):
n = len(true) # update
num = np.sum(np.square(true - pred)) / n # update
den = np.sum(np.square(pred))
squared_error = num/den
rrmse_loss = np.sqrt(squared_error)
return rrmse_loss
@yustiks
Copy link

yustiks commented Nov 15, 2023

I am sorry, but I do not see 'n' from this formula in the code

@AayushSameerShah
Copy link
Author

Oh! @yustiks thanks for spotting this error! I have updated the code for the same.
And I also have commented on the source (cited as my comment above) to fix this.

Actually I had copied that code from there, and had not verified it thoroughly.
Thanks again!
🍻

@yustiks
Copy link

yustiks commented Nov 17, 2023

Yeah, I found this initial article, and they posted so many formulas with many mistakes. Terrible

@AayushSameerShah
Copy link
Author

Agreed, that actually is a popular website for the content related to data science but often they run "blogathon" which asks volunteers to write the blog for their site, and often these blogs aren't reviewed. 🤷🏻‍♂️

Pardon, I didn't even double-check the code before posting.

@pmingkr
Copy link

pmingkr commented Apr 18, 2024

it seems this formula has an error.
need to divide with the average but it divides with the root average. because the average value is inside of the root.

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