/// <summary> /// Scores the users in <see cref="usageEvents"/> who are also present in <see cref="evaluationUsageEvents"/> /// </summary> /// <param name="model">Model to be used for scoring</param> /// <param name="usageEvents">List of usage events</param> /// <param name="evaluationUsageEvents">List of evaluation events</param> /// <returns></returns> private IList <SarScoreResult> ScoreTestUsers(ITrainedModel model, IList <SarUsageEvent> usageEvents, IList <SarUsageEvent> evaluationUsageEvents) { // Score the test users var evaluationRecommender = new Recommender(model, null, _tracer); // extract the user ids from the evaluation usage events HashSet <uint> evaluationUsers = new HashSet <uint>(evaluationUsageEvents.Select(usageEvent => usageEvent.UserId)); // filter out usage events of users not found in the evaluation set IEnumerable <SarUsageEvent> usageEventsFiltered = usageEvents.Where(usageEvent => evaluationUsers.Contains(usageEvent.UserId)); // group usage event by user, and calculate score List <SarScoreResult> scores = usageEventsFiltered.GroupBy(usageEvent => usageEvent.UserId) .SelectMany(group => evaluationRecommender.ScoreUsageEvents(group.ToList(), RecommendationCount)) .ToList(); return(scores); }