May 2020
Intermediate to advanced
404 pages
10h 52m
English
We use the pivot_table method of the pandas module to create a matrix of user ratings against products. We will use this matrix to perform matrix factorization to determine the products that a user likes:
userRatings = pd.pivot_table(data, values='Score', index=['UserId'], columns=['ProductId'])userRatings.shape
We will also convert the TfidfVectorizer vectors for users and products into matrices suitable for matrix factorization:
P = pd.DataFrame(user_vectors.toarray(), index=user_df.index, columns=user_vectorizer.get_feature_names())Q = pd.DataFrame(product_vectors.toarray(), index=product_df.index, columns=product_vectorizer.get_feature_names())
We can now create the matrix ...
Read now
Unlock full access