jchen8000 commited on
Commit
9c81a28
·
verified ·
1 Parent(s): d2c0601

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -45,13 +45,14 @@ def get_recommendations(title, cosine_sim=cosine_sim):
45
  # Get the movie indices
46
  movie_indices = [i[0] for i in sim_scores]
47
 
48
- # Return the top 10 most similar movies
49
- return movies['title'].iloc[movie_indices]
 
50
 
51
  # Gradio interface
52
  def recommend_movies(movie):
53
  recommendations = get_recommendations(movie)
54
- return recommendations.tolist()
55
 
56
  # Create the Gradio interface
57
  movie_list = movies['title'].tolist()
 
45
  # Get the movie indices
46
  movie_indices = [i[0] for i in sim_scores]
47
 
48
+ # Return the top 10 most similar movies with their scores
49
+ recommendations = [(movies['title'].iloc[i], sim_scores[idx][1]) for idx, i in enumerate(movie_indices)]
50
+ return recommendations
51
 
52
  # Gradio interface
53
  def recommend_movies(movie):
54
  recommendations = get_recommendations(movie)
55
+ return "\n".join([f"{title}: {score:.2f}" for title, score in recommendations])
56
 
57
  # Create the Gradio interface
58
  movie_list = movies['title'].tolist()