public List <SimilarUser <ISvdBoostedKnnUser> > CalculateKNearestNeighbours(ISvdBoostedKnnUser user, IEnumerable <ISvdBoostedKnnUser> users, int nearestNeighboursCount) { var neighbours = new List <SimilarUser <ISvdBoostedKnnUser> >(); foreach (var neighbour in users) { if (neighbour == user) { continue; } var s = CalculateSimilarity(user, neighbour); if (s <= 0.0) { continue; } neighbours.Add(new SimilarUser <ISvdBoostedKnnUser>(neighbour, s)); neighbours.Sort(); while (neighbours.Count > nearestNeighboursCount) { neighbours.RemoveAt(neighbours.Count - 1); } } return(neighbours); }
public override float CalculateSimilarity(ISvdBoostedKnnUser user, ISvdBoostedKnnUser neighbour) { return(base.CalculateSimilarity(user, neighbour) * ContentSimilarityEstimator.GetSimilarity(user, neighbour)); }
public virtual float CalculateSimilarity(ISvdBoostedKnnUser user, ISvdBoostedKnnUser neighbour) { var s = SimilarityEstimator.GetSimilarity(user, neighbour); return(s); }