Skip to content

Commit

Permalink
Update RecommendationHandler.py
Browse files Browse the repository at this point in the history
  • Loading branch information
khanmhmdi committed Jul 8, 2023
1 parent 0b896ec commit 860eeac
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions RecommendationHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
from ContentBaseOtherFeatures import ContentBaseOtherFeatures
from ContentBaseMovieStory import ContentBaseMovieStory
from CollaborativeBasedRecommendation import CollaborativeBasedRecommendation
from huggingface_hub import hf_hub_download


class RecommendationHandler:
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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 860eeac

Please sign in to comment.