dataprincess commited on
Commit
25f70a1
·
verified ·
1 Parent(s): ecf2a21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -25,7 +25,7 @@ model.fit(trainset)
25
  def recommend_laptops(age=None, category=None, gender=None, user_id=None, num_recommendations=5):
26
  if user_id is not None:
27
  # Existing user
28
- user_ratings = user_df[user_interactions['User_ID'] == user_id]
29
  user_unrated_laptops = laptop_df[~laptop_df['Laptop_ID'].isin(user_ratings['Laptop_ID'])]
30
  user_unrated_laptops['Predicted_Rating'] = user_unrated_laptops['Laptop_ID'].apply(lambda x: model.predict(user_id, x).est)
31
  recommendations = user_unrated_laptops.sort_values(by='Predicted_Rating', ascending=False).head(num_recommendations)
 
25
  def recommend_laptops(age=None, category=None, gender=None, user_id=None, num_recommendations=5):
26
  if user_id is not None:
27
  # Existing user
28
+ user_ratings = user_df[user_df['User_ID'] == user_id]
29
  user_unrated_laptops = laptop_df[~laptop_df['Laptop_ID'].isin(user_ratings['Laptop_ID'])]
30
  user_unrated_laptops['Predicted_Rating'] = user_unrated_laptops['Laptop_ID'].apply(lambda x: model.predict(user_id, x).est)
31
  recommendations = user_unrated_laptops.sort_values(by='Predicted_Rating', ascending=False).head(num_recommendations)