The Apriori implementation

The goal of this chapter is to produce rules of the following form: if a person recommends these movies, they will also recommend this movie. We will also discuss extensions where a person recommends a set of movies is likely to recommend another particular movie.

To do this, we first need to determine if a person recommends a movie. We can do this by creating a new feature Favorable, which is True if the person gave a favorable review to a movie:

all_ratings["Favorable"] = all_ratings["Rating"] > 3

We can see the new feature by viewing the dataset:

all_ratings[10:15]
 

UserID

MovieID

Rating

Datetime

Favorable

10

62

257

2

1997-11-12 22:07:14

False

11

286

1014

5

1997-11-17 15:38:45

True

12

200

222 ...

Get Python: Real-World Data Science 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.