<jupyter_start><jupyter_text>Import PMF class<jupyter_code>cwd = os.getcwd()
path = os.path.join(cwd, '..', 'src')
if not path in sys.path:
    sys.path.append(path)
del cwd, path
from MovieRecommender import PMF<jupyter_output><empty_output><jupyter_text>Load ratings data<jupyter_code>cwd = os.getcwd()
ratings = pd.read_csv(os.path.join(cwd, "..", "data", "ratings.csv"))
ratings.drop('timestamp', axis=1, inplace=True)
ratings.head()<jupyter_output><empty_output><jupyter_text>Define Adam's userid<jupyter_code>max_userId = ratings['userId'].max()
adam_id = max_userId + 1
print('Adam userid: ' + str(adam_id))<jupyter_output><empty_output><jupyter_text>Load Adam's ratings profile and union it with the ratings data<jupyter_code>adam = pd.read_csv('adam_profile.csv', index_col=0)
adam['userId'] = adam_id
adam = adam[['userId', 'movieId', 'rating']]
adam.head()
ratings.shape[0] + adam.shape[0]
ratings_combined = pd.concat([ratings, adam])
ratings_combined.shape
ratings_combined.head()
ratings_combined.isnull().sum()<jupyter_output><empty_output><jupyter_text>Fit PMF using all data, including Adam's ratings<jupyter_code>pmf = PMF(rank=10, lamd=7.5, sig2=0.5, verbose=True)
pmf.fit(ratings_combined)<jupyter_output>force_refresh is set to: True
persisting user mapping
persisting movie mapping
building omega | 2017-08-08 17:02:12.512816
building omega_u | 2017-08-08 17:02:35.681375
building omega_v | 2017-08-08 19:05:12.426757
building the matrix dictionary M | 2017-08-08 19:29:09.337894
beginning training epochs | 2017-08-08 19:30:49.966994
iteration 10 of 50 | 2017-08-08 20:28:57.254689
iteration 20 of 50 | 2017-08-08 21:34:10.580610
iteration 30 of 50 | 2017-08-08 22:38:33.584332
iteration 40 of 50 | 2017-08-08 23:43:07.185445
iteration 50 of 50 | 2017-08-09 00:47:45.841756<jupyter_text>Persist model<jupyter_code>pickle.dump(pmf, open('adam_pmf_model_trained.pkl', "wb"))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1412987012987013, 'fraction_numerical': 0.12051948051948053, 'mean_word_length': 7.025, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '234441', 'license': 'Apache-2.0', 'n_tokens_mistral': 938, 'n_tokens_neox': 761, 'n_words': 146, 'path': 'notebooks/user_item_recommendations/6a-model-train-PMF-adam.ipynb', 'repo_name': 'statisticianinstilettos/my-movie-recommender', 'size': '1925'}