All Data Labs

Machine learning

Streaming Recommendation System

hard4–5 hours3 datasetsPremium

The whole brief is open to read. This lab's datasets come with Premium.

Company
Amazon Prime Video
Job positions
Data ScientistML EngineerProduct Analyst
Topics
Recommender systemsCollaborative filteringRanking metricsCold startpandas

The scenario

Amazon Prime Video: Build a recommender that ranks ten titles per viewing profile, and beat showing everybody the most popular ones.

The top row of the Amazon Prime Video home screen has ten slots, and it decides what most people watch. Filling it with whatever is most popular works better than it sounds, so that is the bar to clear. Two rules are fixed: a child's profile must never see an adult title, and nobody should be offered what they already finished. You're a data scientist on the discovery team, filling that row.

Your task

Recommend ten titles, in order, for every viewing profile using the viewing history up to August 31, 2025, and beat a most-popular baseline on the two weeks that follow.

Instructions

  1. 1Load and clean the viewing data, handling repeated rows and profiles that watched the same title more than once.
  2. 2Decide what counts as a watch. Some sessions are a few minutes long, which says the viewer did not want it, so choose a rule from minutes watched against runtime and justify where you put the line.
  3. 3Build the most-popular baseline first and score it on the two weeks after the history ends, so you know what you have to beat.
  4. 4Build at least two recommenders and compare them. Titles watched by the same profiles is one approach, and a profile's genre history against the catalog is another.
  5. 5Apply the rules: a profile set up for a child may only be offered titles rated G, TV-Y, TV-G or PG, and no profile should be offered a title it already watched through.
  6. 6Check how your recommender treats the titles added in the last month of history, which have almost no viewing behind them, and say what you did about it.
  7. 7Score on the held-out weeks with recall at ten, and with a rank-aware measure such as NDCG, since the first slot is worth more than the tenth. Save recommendations.csv with the columns profile_id, rank and title_id.

Datasets

All files come in one download.

views.csv

About 26,000 viewing sessions from April 1 to August 31, 2025.

25,583 rows · 6 columns · 1.3 MB

ColumnTypeDescription
view_idintegerUnique ID of the viewing session.
profile_idtextThe profile that watched.
title_idtextThe title watched.
started_atdatetimeWhen the session started.
minutes_watchedintegerMinutes watched in the session. Can be more than one episode's runtime for a series, where people watch several in a sitting.
devicetextfire_tv, smart_tv, mobile, web or tablet.
Preview the first 5 rows
view_idprofile_idtitle_idstarted_atminutes_watcheddevice
9100001PR40000T12382025-08-01 08:53:00130tablet
9100002PR40000T10882025-04-29 07:29:0058tablet
9100003PR40000T11132025-06-27 13:53:00176tablet
9100004PR40000T12712025-05-26 17:20:0085tablet
9100005PR40001T11152025-05-16 19:14:0073fire_tv

titles.csv

The 600 titles in the catalog, including 40 added during August 2025.

600 rows · 9 columns · 40 KB

ColumnTypeDescription
title_idtextUnique ID of the title.
title_nametextName of the title.
title_typetextmovie or series.
genrestextOne or two genres, separated by a vertical bar.
release_yearintegerYear the title was released.
runtime_minutesintegerRuntime of a movie, or of a typical episode for a series.
maturity_ratingtextG, TV-Y, TV-G, PG, PG-13, TV-14, R or TV-MA.
added_ondateDate the title was added to the catalog.
is_originaltextWhether the title is an original production: yes or no.
Preview the first 5 rows
title_idtitle_nametitle_typegenresrelease_yearruntime_minutesmaturity_ratingadded_onis_original
T1000Killing Eveseriesthriller|drama201842TV-142024-11-09no
T1001Crazy Rich Asiansmoviecomedy|romance2018120PG-132022-04-18no
T1002Thor: Ragnarokmovieaction|comedy2017130PG-132025-02-17no
T1003My Neighbor Totoromoviekids|drama198886G2024-11-18no
T1004Being the Ricardosmoviedrama2021131R2022-03-05yes

profiles.csv

The 2,000 viewing profiles, several to a household.

2,000 rows · 5 columns · 57 KB

ColumnTypeDescription
profile_idtextUnique ID of the profile.
household_idtextThe account the profile belongs to. Profiles in one household share a subscription.
countrytextCountry the account is registered in.
signup_monthmonthMonth the account was created.
is_kids_profiletextWhether the profile is set up for a child: yes or no.
Preview the first 5 rows
profile_idhousehold_idcountrysignup_monthis_kids_profile
PR40000H70002IN2025-02no
PR40001H70002US2019-04no
PR40002H70002IN2023-09yes
PR40003H70003US2022-12no
PR40004H70003US2021-11no

Hints

Score the popularity baseline before building anything else. It takes a few lines and it is the number your work has to be worth.

popular = watched.groupby("title_id")["profile_id"].nunique().sort_values(ascending=False)
popular.head(10).index

Dividing a title's co-viewing score by how popular it is stops every recommendation collapsing back onto the same ten blockbusters.

score = co_watch_count / np.sqrt(title_popularity)

Deliverable

A public GitHub repo with your analysis (a notebook or scripts), recommendations.csv with ten ranked titles per profile, and a README with your rule for what counts as a watch, your comparison against the popularity baseline, and how you handled new titles.

When you're done, post your repo in the Solutions tab to share it with other learners.

What grading checks

Use this checklist to review your own work before you post and share it.

  • Submitted GitHub repo is public and reachable.
  • Repo contains at least one notebook or script file.
  • recommendations.csv has exactly ten distinct titles, ranked 1 to 10, for every profile.
  • No profile set up for a child is offered a title rated above PG, and no profile is offered a title it already watched through.
  • Recall at ten on the held-out weeks reaches at least 0.13, against 0.113 for recommending the most popular titles to everybody.
  • A rule for what counts as a watch is chosen from minutes watched against runtime and justified, and at least two recommenders are compared against the popularity baseline.
  • The titles added in the last month can be recommended at all, and a rank-aware measure such as NDCG is reported alongside recall.