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); }
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); }