jchen8000 commited on
Commit
e67968d
·
verified ·
1 Parent(s): 87dfed9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -8
app.py CHANGED
@@ -157,9 +157,6 @@ autoencoder.fit(movie_user_matrix_scaled, movie_user_matrix_scaled,
157
  epochs=50, batch_size=64, shuffle=True, validation_split=0.2,
158
  verbose=0)
159
 
160
-
161
-
162
-
163
  # Use the trained autoencoder to predict the complete matrix
164
  predicted_matrix_scaled = autoencoder.predict(movie_user_matrix_scaled)
165
  predicted_matrix = scaler.inverse_transform(predicted_matrix_scaled)
@@ -225,30 +222,42 @@ total_movies = len(movies)
225
 
226
  with gr.Blocks() as iface:
227
  with gr.Tab("Content-Based Filtering"):
 
 
 
 
 
 
228
  gr.Interface(fn=recommend_movies_cb,
229
  inputs=gr.Dropdown(movie_list, label=f"Select a Movie (Total movies: {total_movies}, randomly list {input_count} for demo purpose.)"),
230
  outputs=[gr.Textbox(label="Recommended Movies:")],
231
- title="Movie Recommender - Content-Based Filtering",
232
  description="Select a movie to get recommendations based on content filtering.")
233
 
234
  with gr.Tab("Collaborative Filtering"):
235
- gr.Markdown("""# Movie Recommender - Item-Based Collaborative Filtering
236
  * Create a movie-user matrix where rows represent movies and columns represent users, each cell contains the rating a user gave to a movie, or 0 if no rating exists.
237
  * Calculate the cosine similarity between movies based on their rating patterns, results in a movie-movie similarity matrix.
238
  * For a given movie, find the most similar movies based on this similarity matrix, and recommend these movies.
 
239
  """)
240
  gr.Interface(fn=recommend_movies_cf,
241
  inputs=gr.Dropdown(movie_list, label=f"Select a Movie (Total movies: {total_movies}, randomly list {input_count} for demo purpose.)"),
242
  outputs=[gr.Textbox(label="Recommended Movies:")],
243
- title="Movie Recommender - Item-Based Collaborative Filtering",
244
  description="Select a movie to get recommendations based on collaborative filtering.")
245
 
246
  with gr.Tab("Collaborative Filtering with Neural Network"):
247
- gr.Markdown("A Neural Network is used to predict the missing values in the movie-user matrix, which should improve our collaborative filtering recommendations.")
 
 
 
 
 
248
  gr.Interface(fn=recommend_movies_cfnn,
249
  inputs=gr.Dropdown(movie_list, label=f"Select a Movie (Total movies: {total_movies}, randomly list {input_count} for demo purpose.)"),
250
  outputs=[gr.Textbox(label="Recommended Movies:")],
251
- title="Movie Recommender - Item-Based Collaborative Filtering",
252
  description="Select a movie to get recommendations based on collaborative filtering.")
253
 
254
  # Launch the app
 
157
  epochs=50, batch_size=64, shuffle=True, validation_split=0.2,
158
  verbose=0)
159
 
 
 
 
160
  # Use the trained autoencoder to predict the complete matrix
161
  predicted_matrix_scaled = autoencoder.predict(movie_user_matrix_scaled)
162
  predicted_matrix = scaler.inverse_transform(predicted_matrix_scaled)
 
222
 
223
  with gr.Blocks() as iface:
224
  with gr.Tab("Content-Based Filtering"):
225
+ gr.Markdown("""## Movie Recommender - Content-Based Filtering
226
+ * Use the 'genres' feature of movies, and convert genres into numerical vectors.
227
+ * For a given movie, find the most similar movies based on the genre similarity.
228
+ * This approach uses genres of movies only, without considering user preferences or viewing history.
229
+ * Simple to implement and computationally efficient, but doesn't handle sparsity well (when many missing ratings).
230
+ """)
231
  gr.Interface(fn=recommend_movies_cb,
232
  inputs=gr.Dropdown(movie_list, label=f"Select a Movie (Total movies: {total_movies}, randomly list {input_count} for demo purpose.)"),
233
  outputs=[gr.Textbox(label="Recommended Movies:")],
234
+ # title="Movie Recommender - Content-Based Filtering",
235
  description="Select a movie to get recommendations based on content filtering.")
236
 
237
  with gr.Tab("Collaborative Filtering"):
238
+ gr.Markdown("""## Movie Recommender - Item-Based Collaborative Filtering
239
  * Create a movie-user matrix where rows represent movies and columns represent users, each cell contains the rating a user gave to a movie, or 0 if no rating exists.
240
  * Calculate the cosine similarity between movies based on their rating patterns, results in a movie-movie similarity matrix.
241
  * For a given movie, find the most similar movies based on this similarity matrix, and recommend these movies.
242
+ * Simple to implement and computationally efficient, but doesn't handle sparsity well (when many missing ratings).
243
  """)
244
  gr.Interface(fn=recommend_movies_cf,
245
  inputs=gr.Dropdown(movie_list, label=f"Select a Movie (Total movies: {total_movies}, randomly list {input_count} for demo purpose.)"),
246
  outputs=[gr.Textbox(label="Recommended Movies:")],
247
+ # title="Movie Recommender - Item-Based Collaborative Filtering",
248
  description="Select a movie to get recommendations based on collaborative filtering.")
249
 
250
  with gr.Tab("Collaborative Filtering with Neural Network"):
251
+ gr.Markdown("""## Movie Recommender - Item-Based Collaborative Filtering with Neural Network
252
+ * Use a Neural Network to predict the missing values in the movie-user matrix to improve the collaborative filtering recommendations.
253
+ * The NN model learns to reconstruct the movie-user matrix, effectively predicting missing ratings. This results in a dense, predicted movie-user matrix.
254
+ * Calculate movie-movie similarities using the predicted matrix. And use this similarity matrix to find and recommend similar movies.
255
+ * This approach often provides more accurate recommendations especially with large sparse datasets. But more complex to implement and require more computational resources.
256
+ """)
257
  gr.Interface(fn=recommend_movies_cfnn,
258
  inputs=gr.Dropdown(movie_list, label=f"Select a Movie (Total movies: {total_movies}, randomly list {input_count} for demo purpose.)"),
259
  outputs=[gr.Textbox(label="Recommended Movies:")],
260
+ # title="Movie Recommender - Item-Based Collaborative Filtering",
261
  description="Select a movie to get recommendations based on collaborative filtering.")
262
 
263
  # Launch the app