Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,9 @@ import gradio as gr
|
|
5 |
import zipfile
|
6 |
import requests
|
7 |
import io
|
|
|
|
|
|
|
8 |
|
9 |
# Download and extract the MovieLens dataset
|
10 |
url = 'https://files.grouplens.org/datasets/movielens/ml-latest-small.zip'
|
@@ -57,10 +60,10 @@ def recommend_movies(movie):
|
|
57 |
return "Score Title\n" + "\n".join([format_string.format(score, title) for title, score in recommendations])
|
58 |
|
59 |
# Create the Gradio interface
|
60 |
-
movie_list = movies['title'].tolist()
|
61 |
total_movies = len(movies)
|
62 |
iface = gr.Interface(fn=recommend_movies,
|
63 |
-
inputs=gr.Dropdown(movie_list, label=f"Select a Movie (Total movies: {total_movies})"),
|
64 |
outputs="text",
|
65 |
title="Movie Recommender - Content-Based Filtering",
|
66 |
description="Select a movie to get recommendations based on content filtering.")
|
|
|
5 |
import zipfile
|
6 |
import requests
|
7 |
import io
|
8 |
+
import random
|
9 |
+
|
10 |
+
input_count = 200
|
11 |
|
12 |
# Download and extract the MovieLens dataset
|
13 |
url = 'https://files.grouplens.org/datasets/movielens/ml-latest-small.zip'
|
|
|
60 |
return "Score Title\n" + "\n".join([format_string.format(score, title) for title, score in recommendations])
|
61 |
|
62 |
# Create the Gradio interface
|
63 |
+
movie_list = random.sample(movies['title'].tolist(), input_count)
|
64 |
total_movies = len(movies)
|
65 |
iface = gr.Interface(fn=recommend_movies,
|
66 |
+
inputs=gr.Dropdown(movie_list, label=f"Select a Movie (Total movies: {total_movies}, randomly list {input_count} for demo purpose.)"),
|
67 |
outputs="text",
|
68 |
title="Movie Recommender - Content-Based Filtering",
|
69 |
description="Select a movie to get recommendations based on content filtering.")
|