clfegg commited on
Commit
d06e555
1 Parent(s): 4649329

Delete model.py

Browse files
Files changed (1) hide show
  1. model.py +0 -13
model.py DELETED
@@ -1,13 +0,0 @@
1
- import numpy as np
2
- import pandas as pd
3
-
4
- class ContentBasedRecommender:
5
- def __init__(self, train_data):
6
- self.train_data = train_data
7
-
8
- def predict(self, user_id, k=10):
9
- user_books = set(self.train_data[self.train_data['user_id'] == user_id]['book_id'])
10
- similar_books = set().union(*(self.train_data[self.train_data['book_id'] == book_id]['similar_books'].iloc[0] for book_id in user_books))
11
- recommended_books = list(similar_books - user_books)
12
-
13
- return np.random.choice(recommended_books, size=min(k, len(recommended_books)), replace=False).tolist()