public HtmlString GetRecommendedVids(int userID) { RecommendedWatchML ml = new RecommendedWatchML(); ML_BL ml_bl = new ML_BL(); List <VideoRepository> recommendedWatch = new List <VideoRepository>(); var topics = ml_bl.GetUserTopics(userID); //Use ML to determine best recommended video based on interests var MLOutputs = ml.GetRecommendationsFromInterests(topics); if (MLOutputs.Any()) { recommendedWatch.AddRange(dal.GetRecommendedVids(userID, whereIn: MLOutputs.Select(z => (int)z.VideoId).ToList())); } if (MLOutputs.Count < 5) { recommendedWatch.AddRange(dal.GetRecommendedVids(userID, top: 5 - MLOutputs.Count, whereNotIn: MLOutputs.Select(z => (int)z.VideoId).ToList())); } var vidsStr = ConvertVidGridHTMLSting(recommendedWatch); return(new HtmlString(vidsStr)); }
internal HtmlString GetNextRecommendedWatch(Guid videoId) { ML_BL ml_bl = new ML_BL(); // Get the ML Id from the table - each video is linked to two unique identifier, a GUID which is used by the applicable web-side and an int used by the ML var MLVideoId = ml_bl.GetMLVideoId(videoId); RecommendedWatchML ml = new RecommendedWatchML(); var MLOutputs = ml.GetRecommendationsFromPreviousWatch(MLVideoId); // Get Recommendation from trained model if (MLOutputs.Any()) { return(new HtmlString(ConvertVidGridHTMLSting(dal.GetVideoByMLId(MLOutputs.Select(z => (int)z.nextWatch).ToList()), withSVG: false))); } else { return(null); } }