Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,8 +30,6 @@ indices = pd.Series(movies.index, index=movies['title']).drop_duplicates()
|
|
30 |
|
31 |
# Function that takes in movie title as input and outputs most similar movies
|
32 |
def get_recommendations(title, cosine_sim=cosine_sim):
|
33 |
-
if not title:
|
34 |
-
return "No movie selected. Please select one from the dropdown."
|
35 |
|
36 |
# Get the index of the movie that matches the title
|
37 |
idx = indices[title]
|
@@ -54,8 +52,10 @@ def get_recommendations(title, cosine_sim=cosine_sim):
|
|
54 |
|
55 |
# Gradio interface
|
56 |
def recommend_movies(movie):
|
|
|
|
|
|
|
57 |
recommendations = get_recommendations(movie)
|
58 |
-
|
59 |
format_string = "{:>5.2f} {:<20}"
|
60 |
return "Score Title\n" + "\n".join([format_string.format(score, title) for title, score in recommendations])
|
61 |
|
|
|
30 |
|
31 |
# Function that takes in movie title as input and outputs most similar movies
|
32 |
def get_recommendations(title, cosine_sim=cosine_sim):
|
|
|
|
|
33 |
|
34 |
# Get the index of the movie that matches the title
|
35 |
idx = indices[title]
|
|
|
52 |
|
53 |
# Gradio interface
|
54 |
def recommend_movies(movie):
|
55 |
+
if not movie:
|
56 |
+
return "No movie selected. Please select one from the dropdown."
|
57 |
+
|
58 |
recommendations = get_recommendations(movie)
|
|
|
59 |
format_string = "{:>5.2f} {:<20}"
|
60 |
return "Score Title\n" + "\n".join([format_string.format(score, title) for title, score in recommendations])
|
61 |
|