Upload 5_netflix_genre.md with huggingface_hub
Browse files- 5_netflix_genre.md +42 -0
5_netflix_genre.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Classifying Netflix Titles by Genre Using TF-IDF and Logistic Regression
|
| 2 |
+
|
| 3 |
+
When a streaming platform recommends "because you watched X," genre is a big part of the matching. In this project I built a classifier that reads a Netflix title's name and description and guesses its primary genre — automatically. No human tagging required.
|
| 4 |
+
|
| 5 |
+
## The Data
|
| 6 |
+
|
| 7 |
+
I used the Netflix Movies and TV Shows dataset (8,807 titles with 12 columns). For this task the two most important columns are:
|
| 8 |
+
|
| 9 |
+
- `title` + `description` — the input text
|
| 10 |
+
- `listed_in` — the genre labels
|
| 11 |
+
|
| 12 |
+
I took the first genre in `listed_in` as the primary genre and kept only genres with at least 20 examples, which left **26 genre classes**. Popular ones include Dramas, Comedies, Action & Adventure, Documentaries, and International TV Shows.
|
| 13 |
+
|
| 14 |
+
## The Approach
|
| 15 |
+
|
| 16 |
+
My pipeline was deliberately simple and fast:
|
| 17 |
+
|
| 18 |
+
1. **TF-IDF vectorization** — converts the title + description text into numbers, weighing words by how informative they are (common words get downweighted).
|
| 19 |
+
2. **Logistic Regression** — a linear classifier. Logistic regression on TF-IDF is a classic NLP baseline that is cheap to train and easy to interpret. It handles 26 classes via one-vs-rest.
|
| 20 |
+
|
| 21 |
+
## Results
|
| 22 |
+
|
| 23 |
+
- **Test accuracy: 45.9%** across 26 classes
|
| 24 |
+
|
| 25 |
+
45.9% sounds modest, but guess a random genre out of 26 and you'd hit about 3.8%. So the model is learning real patterns — it just cannot always pin down genres that blend together (is it a Drama, a Comedy, or both?).
|
| 26 |
+
|
| 27 |
+
## What Didn't Work (and What Would Help)
|
| 28 |
+
|
| 29 |
+
The accuracy ceiling here comes mostly from the labels themselves. Netflix genres overlap heavily — a "Romantic Comedies" title is both Romance and Comedy, and there's genuine ambiguity even for a human. The description text is also short, so there's limited signal.
|
| 30 |
+
|
| 31 |
+
The clear improvements are:
|
| 32 |
+
- Use the **full genre list** instead of just the primary one (multi-label classification).
|
| 33 |
+
- Try a transformer embedding instead of TF-IDF for richer understanding.
|
| 34 |
+
- Feed in cast and director as extra features.
|
| 35 |
+
|
| 36 |
+
## Key Takeaways
|
| 37 |
+
|
| 38 |
+
- TF-IDF + Logistic Regression is a fast, dependable baseline that handles text classification with almost no tuning.
|
| 39 |
+
- Multi-class accuracy should always be judged against the "random guess" baseline, not against 100%.
|
| 40 |
+
- When the labels overlap, a multi-label formulation matches the problem better than a single-label one.
|
| 41 |
+
|
| 42 |
+
The classifier is published on Kaggle as a ready-to-load sklearn Pipeline, with a demo notebook that classifies any new title+description you paste in.
|