Skip to content

Instantly share code, notes, and snippets.

@sudipto80
Created January 21, 2016 08:41
Show Gist options
  • Save sudipto80/8fc75f804e04d80b15c7 to your computer and use it in GitHub Desktop.
Save sudipto80/8fc75f804e04d80b15c7 to your computer and use it in GitHub Desktop.
Mean Squarred Errors
//Mean Absolute Error
let mae (ratings:float list)(predictions:float list) =
(List.zip ratings predictions |> List.sumBy (fun t -> abs (fst t - snd t)))
/float ratings.Length
//Normalized Mean Absolute Error
let nmae (ratings:float list)(predictions:float list) =
let rMax = ratings |> List.max
let rMin = ratings |> List.min
(mae ratings predictions )/(rMax - rMin)
//Root mean squared error
let rmse(ratings:float list)(predictions:float list) =
sqrt( ( List.zip ratings predictions
|> List.map (fun t -> fst t - snd t)
|> List.sum )
/(float predictions.Length ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment