Exemple #1
0
        public IReadOnlyCollection <SimilarMovies> GetSimilarMovies(Movie m, User[] users, int count = 100)
        {
            BestKeeper <SimilarMovies> best = new BestKeeper <SimilarMovies>(count,
                                                                             (m1, m2) => Math.Sign(m1.Similarity - m2.Similarity));

            foreach (var movie in Movies)
            {
                if (movie != m)
                {
                    best.AddCandidate(new SimilarMovies(movie, SimilarityPearson(m, movie, users)));
                }
            }
            return(best);
        }
Exemple #2
0
        public IReadOnlyCollection <SimilarUser> GetSimilarUsers(User u, int count = 100)
        {
            BestKeeper <SimilarUser> best = new BestKeeper <SimilarUser>(count,
                                                                         (u1, u2) => Math.Sign(u1.Similarity - u2.Similarity));

            foreach (var other in Users)
            {
                if (other != u)
                {
                    best.AddCandidate(new SimilarUser(other, SimilarityPearson(u, other)));
                }
            }
            return(best);
        }