Created
January 21, 2016 08:55
-
-
Save sudipto80/d257f8da8ed32b16fec3 to your computer and use it in GitHub Desktop.
base line predictor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Non personalized baseline predictor | |
let baseline (ratings:(float list)list) = | |
let mu = ratings |> List.map ( fun ra -> [for i in 0 .. ra.Length - 1 -> ra.[i]] | |
|> List.filter (fun t -> t <> 0.0) | |
|> List.average) | |
|> List.average | |
let mutable bu = ratings |> List.sumBy (fun rating -> [for i in 0 .. rating.Length - 1 -> rating.[i]] | |
|> List.filter (fun ri -> ri <> 0.0) | |
|> List.sumBy (fun ri -> ri - mu)) | |
bu <- bu / float ratings.[0].Length | |
let mutable bi = ratings |> List.sumBy (fun ra -> [for i in 0 .. ra.Length - 1 -> ra.[i]] | |
|> List.filter (fun t -> t <> 0.0) | |
|> List.sumBy (fun z -> z - bu - mu)) | |
bi <- bi / float ratings.Length | |
mu + bu + bi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got here from the link in your "F# Machine Learning Essentials" book. However, you don't explain this formula neither in the book nor in this code. It would be very nice if you could explain the calculations. Thanks.