Skip to content

Commit

Permalink
Change load_training_data method interface
Browse files Browse the repository at this point in the history
  • Loading branch information
domainxz committed Jan 3, 2020
1 parent 0fe5933 commit f3481f2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions single/wmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ def __init__(self, k: int, lu: float = 0.01, lv: float = 0.01, a: float = 1, b:
self.fue = None
self.fie = None

def load_training_data(self, upath: str, ipath: str, trpath: str) -> None:
self.uids = get_id_dict_from_file(upath)
def load_training_data(self, uid_file: str, iid_file: str, tr_file: str) -> None:
self.uids = get_id_dict_from_file(uid_file)
self.n_users = len(self.uids)
self.usm = dict()
for uid in self.uids.values():
self.usm[uid] = list()
self.iids = get_id_dict_from_file(ipath)
self.iids = get_id_dict_from_file(iid_file)
self.n_items = len(self.iids)
self.n_ratings = self.n_users * self.n_items
self.ism = dict()
for iid in self.iids.values():
self.ism[iid] = list()
for line in open(trpath, 'r'):
for line in open(tr_file, 'r'):
terms = line.strip().split(',')
uid = terms[0]
for j in range(1, len(terms)):
Expand Down

0 comments on commit f3481f2

Please sign in to comment.