From 860eeac2ae4ae32ca09f010449d4896ab277ab4b Mon Sep 17 00:00:00 2001 From: Mohamadreza Khanmohamadi <53315077+khanmhmdi@users.noreply.github.com> Date: Sat, 8 Jul 2023 15:48:38 +0330 Subject: [PATCH] Update RecommendationHandler.py --- RecommendationHandler.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/RecommendationHandler.py b/RecommendationHandler.py index e8eab9e..9d2f482 100644 --- a/RecommendationHandler.py +++ b/RecommendationHandler.py @@ -3,6 +3,7 @@ from ContentBaseOtherFeatures import ContentBaseOtherFeatures from ContentBaseMovieStory import ContentBaseMovieStory from CollaborativeBasedRecommendation import CollaborativeBasedRecommendation +from huggingface_hub import hf_hub_download class RecommendationHandler: @@ -10,9 +11,14 @@ def __init__(self, user_movies): self.user_movies = user_movies def get_ContentBaseOtherFeatures(self): - model_path = './MovieRecommendation/Recommender_System/master_ui/Models/genres_cast_keywords_crew Model/cosine_sim.pkl' - data_path = './MovieRecommendation/Recommender_System/master_ui/Models/genres_cast_keywords_crew Model/data.csv' - indices_path = './MovieRecommendation/Recommender_System/master_ui/Models/genres_cast_keywords_crew Model/indices.csv' + # model_path = './MovieRecommendation/Recommender_System/master_ui/Models/genres_cast_keywords_crew Model/cosine_sim.pkl' + # data_path = './MovieRecommendation/Recommender_System/master_ui/Models/genres_cast_keywords_crew Model/data.csv' + # indices_path = './MovieRecommendation/Recommender_System/master_ui/Models/genres_cast_keywords_crew Model/indices.csv' + + model_path = hf_hub_download(repo_id="Khanmhmdi/Collaborative-movie-recommendation-systems", filename="ContentBase Models/genres_cast_keywords_crew Model/cosine_sim.pkl") + data_path = hf_hub_download(repo_id="Khanmhmdi/Collaborative-movie-recommendation-systems", filename="ContentBase Models/genres_cast_keywords_crew Model/data.csv") + indices_path = hf_hub_download(repo_id="Khanmhmdi/Collaborative-movie-recommendation-systems", filename="ContentBase Models/genres_cast_keywords_crew Model/indices.csv") + movie_ContBF_R = ContentBaseOtherFeatures(model_path, data_path, indices_path) ContBF_result = [] for i in self.user_movies: @@ -25,9 +31,14 @@ def get_ContentBaseOtherFeatures(self): return ContBF_result def get_ContentBaseMovieStory(self): - model_path = './MovieRecommendation/Recommender_System/master_ui/Models/Overview Model/cosine_sim.pkl' - titles_path = './MovieRecommendation/Recommender_System/master_ui/Models/Overview Model/titles.csv' - indices_path = './MovieRecommendation/Recommender_System/master_ui/Models/Overview Model/indices.csv' + # model_path = './MovieRecommendation/Recommender_System/master_ui/Models/Overview Model/cosine_sim.pkl' + # titles_path = './MovieRecommendation/Recommender_System/master_ui/Models/Overview Model/titles.csv' + # indices_path = './MovieRecommendation/Recommender_System/master_ui/Models/Overview Model/indices.csv' + + indices_path = hf_hub_download(repo_id="Khanmhmdi/Collaborative-movie-recommendation-systems", filename="ContentBase Models/Overview Model/indices.csv") + titles_path = hf_hub_download(repo_id="Khanmhmdi/Collaborative-movie-recommendation-systems", filename="ContentBase Models/Overview Model/titles.csv") + model_path = hf_hub_download(repo_id="Khanmhmdi/Collaborative-movie-recommendation-systems", filename="ContentBase Models/Overview Model/cosine_sim.pkl") + movie_ContBMS_R = ContentBaseMovieStory(model_path, titles_path, indices_path) ContBMS_results = [] for i in self.user_movies: @@ -39,9 +50,15 @@ def get_ContentBaseMovieStory(self): return ContBMS_results def get_CollaborativeBasedRecommendation(self): - rating_df_path = './MovieRecommendation/Recommender_System/master_ui/Models/Collaborative Model/ratings_df.csv' - movies_df_path = './MovieRecommendation/Recommender_System/master_ui/Models/Collaborative Model/movies_df.csv' - model_path = './MovieRecommendation/Recommender_System/master_ui/Models/Collaborative Model/colab.pth' + # rating_df_path = './MovieRecommendation/Recommender_System/master_ui/Models/Collaborative Model/ratings_df.csv' + # movies_df_path = './MovieRecommendation/Recommender_System/master_ui/Models/Collaborative Model/movies_df.csv' + # model_path = './MovieRecommendation/Recommender_System/master_ui/Models/Collaborative Model/colab.pth' + model_path = hf_hub_download(repo_id="Khanmhmdi/Collaborative-movie-recommendation-systems", + filename="Collaborative Model/learners.pkl") + movies_df_path = hf_hub_download(repo_id="Khanmhmdi/Collaborative-movie-recommendation-systems", + filename="Collaborative Model/movies_df.csv") + rating_df_path = hf_hub_download(repo_id="Khanmhmdi/Collaborative-movie-recommendation-systems", + filename="Collaborative Model/ratings_df.csv") CollBR_movie = CollaborativeBasedRecommendation(rating_df_path, movies_df_path, model_path) similar_users = CollBR_movie.find_users_seen_only_specific_movies(self.user_movies) if len(similar_users) == 0: