Building Recommendation Engines in Python
Rob O'Callaghan
Director of Data
print(book_rating_df)
title The Great Gatsby The Catcher in the Rye Fifty Shades of Grey
User
User_233 3.0 NaN NaN
User_651 NaN 5.0 4.0
User_965 4.0 3.0 NaN
... ... ... ...
number_of_empty = book_ratings_df.isnull().values.sum()
total_number = user_ratings_df.size
sparsity = number_of_empty/total_number
print(sparsity)
0.0114
user_ratings_df.notnull().sum()
The Pelican Brief 1
Snow Crash 1
The Great Gatsby 12
Fifty Shades of Grey 9
Leviathan 1
..
print(matrix_x)
[[4, 1],
[2, 2],
[3, 3]]
print(matrix_b)
[[1, 0, 4],
[0, 1, 6]]
import numpy as np
dot_product = np.dot(matrix_x, matrix_b)
print(dot_product)
[[ 4 1 22]
[ 2 2 20]
[ 3 3 30]]
Building Recommendation Engines in Python