DEV Community

Abhishek Gupta
Abhishek Gupta

Posted on

How YouTube Recommends Videos: Learn Machine Learning Without Writing Code

🎯 Goal

After this activity, you should understand:

βœ… What is Data

βœ… What is a Dataset

βœ… What is Training Data

βœ… What is a Feature

βœ… What is Training

βœ… What is Prediction

βœ… Why ML needs lots of examples

βœ… How YouTube recommends videos


Step 1 β€” Ask a Simple Question

Imagine you open YouTube.

You watch:

Python Tutorial

A few seconds later, YouTube suggests:

  • React Tutorial
  • JavaScript Course
  • Node.js Crash Course

Question:

How did YouTube know that you might like React?


Did an Engineer Write This?

if user == "Abhishek":
    recommend("React Tutorial")
Enter fullscreen mode Exit fullscreen mode

No.

That would never work.

Why?

Because YouTube has:

  • Billions of users
  • Millions of videos
  • Billions of views every day

No engineer can write rules for every person.

Machine Learning solves this problem.


Step 2 β€” What Does YouTube Collect?

Machine Learning needs examples.

These examples come from data.

YouTube collects things like:

Information Example
Video watched Python Basics
Watch time 15 minutes
Like Yes
Comment Nice video
Search React Tutorial
Device Mobile
Country India
Subscribed Yes

Think Like a Teacher

A teacher teaches students using examples.

Machine Learning also learns from examples.

The only difference is:

Teacher β†’ Students

Data β†’ Machine


Step 3 β€” Give Data to the Machine

This is called Training Data.

We are teaching YouTube.

Dataset:

User Watched Video Next Video
User1 Python Basics React Tutorial
User2 Python Basics React Tutorial
User3 Python Basics Node.js
User4 Python Basics React Tutorial
User5 Cricket Match Highlights
User6 AI News ChatGPT Tutorial
User7 AI News Prompt Engineering
User8 Cooking Pasta Cake Recipe

Important Idea

This table is called a Dataset.

Machine Learning studies this dataset.


Step 4 β€” Become the Machine

Forget computers.

You are now the ML model.

Look only at Python.

Examples:

Python β†’ React

Python β†’ React

Python β†’ Node.js

Python β†’ React

Count them.

React = 3 times

Node.js = 1 time


Step 5 β€” Learn the Pattern

Machine says:

I noticed something.

People who watch Python usually watch React.

Pattern learned:

Python
   ↓
React
Enter fullscreen mode Exit fullscreen mode

Step 6 β€” Training

Training simply means:

Study examples.

Again.

Again.

Again.

Until patterns become clear.

Machine Learning Training = Studying examples.


Step 7 β€” Prediction

A new user comes.

Watched:

Python Basics

Machine asks:

What did similar people watch?

Answer:

React Tutorial

Recommendation:

🎯 React Tutorial


Step 8 β€” Confidence

Machine may think:

React = 80%

Node.js = 15%

Angular = 5%

Best choice?

React.


Step 9 β€” More Data Makes Better ML

Suppose we train with:

10 users

Model is okay.

Train with:

10 million users

Model becomes much smarter.


Step 10 β€” Real YouTube

Real YouTube studies:

Billions of videos watched

Likes

Comments

Searches

Subscriptions

Watch time

Devices

Countries

Age groups

Trending topics

Then ML learns patterns automatically.


Student Activities

Activity 1

Open Excel.

Create the dataset.

Count recommendations.


Activity 2

Add 20 more users.

Example:

Python β†’ Vue

Python β†’ Angular

Python β†’ React

See what changes.


Activity 3

Predict recommendations.

User watched:

AI News

Recommend what?


Activity 4

Create your own recommendation system.

Topics:

Sports

Music

Movies

Travel

Gaming

Teach the machine.


Questions for Students

Q1

What is Data?


Q2

What is a Dataset?


Q3

Why does ML need examples?


Q4

What is Training?


Q5

What is Prediction?


Q6

Why can't YouTube use if-else statements?


Q7

Does more data improve recommendations?

Why?


MCQs

1. What does Machine Learning learn from?

A) Luck

B) Examples

C) Guessing

D) Passwords

βœ… Answer: B


2. What is a Dataset?

A) A game

B) A collection of examples

C) A password

D) A website

βœ… Answer: B


3. What is Training?

A) Writing code

B) Studying examples

C) Buying GPUs

D) Guessing answers

βœ… Answer: B


The Most Important Lesson

Traditional Programming:

Human writes rules
        ↓
Computer follows rules
Enter fullscreen mode Exit fullscreen mode

Machine Learning:

Examples
   ↓
Find patterns
   ↓
Learn relationships
   ↓
Make predictions
   ↓
Improve with more data
Enter fullscreen mode Exit fullscreen mode

One Sentence to Remember

Machine Learning is simply teaching a computer by showing it many examples, just like teaching a child by showing many pictures, videos, or experiences.

Top comments (0)