O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using collaborative filtering on binary data

In the previous two sections, we built recommendation models based on item or user preferences with the data displaying the rating for each purchase. However, in some real-world scenarios, the following two things can take place:

  • We know the items that have been purchased but not their ratings
  • For each user, we don't know which items were purchased but we know which items were liked

In these contexts, we can build a user-item matrix whose values would be 1 if the user purchased (or liked) the item and 0 otherwise. In our case, starting from ratings_movies, we can build a rating_movies_viewed matrix whose values will be 1 if the user viewed the movie and 0 otherwise.

Perform the following steps ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required