Item-based collaborative filtering and recommendations

Item-based collaborative filtering is similar to the user-based approach, except that it uses the similarity measures between items, instead of between users or customers. We had to compute cosine similarities between users before, but now, we are going to compute cosine similarities between items. Take a look at the following code:

item_item_sim_matrix = pd.DataFrame(    cosine_similarity(customer_item_matrix.T))

If you compare this code to the previous code, where we computed a user-to-user similarity matrix, the only difference is the fact that we are transposing the customer_item_matrix here, so that the row indexes represent individual items and the columns represent the customers. ...

Get Hands-On Data Science for Marketing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.