public TSvdBoostedKnnModel TrainKnnModel(TSvdBoostedKnnModel model, List <IUser> trainUsers) { foreach (var user in trainUsers) { model.Users.Add(SvdBoostedKnnUser.FromIUser(user, NewUserFeatureGenerator.GetNewUserFeatures(model, user))); } return(model); }
public IEnumerable <IRecommendation> GenerateRecommendations(IUser user, TSvdBoostedKnnModel model, List <IArtist> artists, int nearestNeighboursCount) { var svdBoostedKnnUser = SvdBoostedKnnUser.FromIUser(user, NewUserFeatureGenerator.GetNewUserFeatures(model, user)); var neighbours = CalculateKNearestNeighbours(svdBoostedKnnUser, model.Users, nearestNeighboursCount); if (neighbours.Count == 0) { return(null); } return(RecommendationGenerator.GenerateRecommendations(svdBoostedKnnUser, neighbours, model, artists)); }
public float PredictRatingForArtist(IUser user, TSvdBoostedKnnModel model, List <IArtist> artists, int artistIndex, int nearestNeighboursCount) { var svdBoostedKnnUser = SvdBoostedKnnUser.FromIUser(user, NewUserFeatureGenerator.GetNewUserFeatures(model, user)); var neighbours = CalculateKNearestNeighbours(svdBoostedKnnUser, model.Users, nearestNeighboursCount); if (neighbours.Count == 0) { return(1.0f); } return(RecommendationGenerator.PredictRatingForArtist(svdBoostedKnnUser, neighbours, model, artists, artistIndex)); }
public override float PredictRatingForArtist(IUser user, ISvdModel model, List <IArtist> artists, int artistIndex) { var newUserFeatures = NewUserFeatureGenerator.GetNewUserFeatures(model, user); var userRating = 0.0f; for (var f = 0; f < model.FeatureCount; f++) { userRating += newUserFeatures[f] * model.ArtistFeatures[f, artistIndex]; } userRating = CapUserRatings(userRating); return(userRating); }
public override float PredictRatingForArtist(IUser user, IBiasSvdModel model, List <IArtist> artists, int artist) { var userBias = user.Ratings.Average(rating => rating.Value - model.GlobalAverage); var newUserFeatures = NewUserFeatureGenerator.GetNewUserFeatures(model, user); var userRating = 0.0f; for (var f = 0; f < model.FeatureCount; f++) { userRating += newUserFeatures[f] * model.ArtistFeatures[f, artist]; } userRating = CapUserRatings(model.GlobalAverage + userBias + model.ArtistBias[artist]); return(userRating); }