Stop 04 · Probability & StatisticsTopics · 5/9

Sampling & Sampling Bias

Part of the Machine Learning Roadmap

In short

You rarely get data on everyone. You get a sample. If the sample is skewed, your answer is wrong, however clever your analysis, and nothing in the numbers will warn you.

You almost never have data on everyone, so you learn from a sample. If the sample is skewed, for example only urban users, the model learns a skewed world and fails on the people who were left out.

The jaadu tastes a spoonful from the top of a big pot of layered biryani.

Think of it like this

Tasting only the top of the biryani

If you taste one spoon from the top of a dum biryani, you'll say it's plain rice. The masala and meat are at the bottom. A good taste needs a spoon that reaches all layers. A good sample needs to reach all kinds of people.

Watch it happen

Two ways to survey app users

Pop-up in the app

  • Only reaches active users
  • Unhappy users who left never see it
  • Satisfaction looks higher than reality

Random sample of all users

  • Includes people who stopped using it
  • Every user has a fair chance
  • Results reflect the whole base

Ask who could not end up in your sample. That missing group is usually where the bias hides.

The big ideas

What you need to know

Random means fair chance

In a random sample every member of the population has a known, fair chance of being picked.

Selection bias

Your collection method favours some people, like surveying only on weekday mornings.

Survivorship bias

Looking only at those who made it. Studying only successful startups hides why others failed.

Self-selection bias

People who choose to respond, like reviewers, are often the very happy or very angry.

Save yourself the pain

Common mistakes

Oops

Thinking a huge sample fixes bias.

Do this instead

A million biased responses are still biased. Fix how you collect before you worry about size.

Oops

Generalising from one city or one week to the whole country or year.

Do this instead

State the limits: 'This is for Mumbai users in March.' Then check if others behave the same.

Your mission

Spot the bias

~15 min

Quick check

A gym surveys members who still attend about satisfaction and gets 92% happy. What's the main problem?

Go deeper

  1. 1List who might be missing from a dataset of app reviews.
  2. 2Compare a random sample with a stratified sample on a pandas DataFrame.
  3. 3Read about survivorship bias and find one example in ML.

Also part of these roadmaps

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge