1

Hello it will be very helpful if some one can help me out with NMAE (Normalized mean average Error to find the accuracy of the model:
NMAE=∑(|predicted rating – real rating|) / n(max rate – min rate) I have given an example how my model is giving the data set output: I have been using R programming for building a recommendation model for movies :

Movie Code  Votes  Real rate  Predicted Rate
1   1371    2.5 2
1   2193    2   3
1   2294    2   3
2   39  5   3
2   50  4   3
2   110 4   4
2   144 3   3
2   153 4   3
2   208 3   3
2   296 4   4
2   372 3   3
2   377 3   3
2   474 2   3
2   500 4   4
2   508 4   3
2   515 4   3
2   539 3   3

Data.

movies <-
structure(list(`Movie Code` = c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), Votes = c(1371L, 2193L, 
2294L, 39L, 50L, 110L, 144L, 153L, 208L, 296L, 372L, 377L, 474L, 
500L, 508L, 515L, 539L), `Real rate` = c(2.5, 2, 2, 5, 4, 4, 
3, 4, 3, 4, 3, 3, 2, 4, 4, 4, 3), `Predicted Rate` = c(2L, 3L, 
3L, 3L, 3L, 4L, 3L, 3L, 3L, 4L, 3L, 3L, 3L, 4L, 3L, 3L, 3L)), class = "data.frame", row.names = c(NA, 
-17L))
Rui Barradas
  • 70,273
  • 8
  • 34
  • 66

1 Answers1

0

You can write a function to compute the NMAE and then pass it any data set you want, small or large.

nmae <- function(DF){
    n <- nrow(DF)
    max_rate <- max(DF[[3]])
    min_rate <- min(DF[[3]])
    sum(abs(DF[[4]] - DF[[3]]))/(n*(max_rate - min_rate))
}

nmae(movies)
#[1] 0.1862745

The function nmae above relies on finding the following columns at the specified positions:

  • column 3 - Real rate
  • column 4 - Predicted Rate

If this is not the case, just change those numbers in the function body and everything will be alright.

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66