Course contentsShow
← Data Science
Lesson 1896 of 2,14544. Data Ethics and PrivacyFree lesson

K-Anonymity

Understand k-anonymity as a method ensuring each record is indistinguishable from k-1 others in the dataset.

K-Anonymity

What you'll learn: How k-anonymity protects individual privacy by ensuring each record blends in with at least k-1 others.


After introducing data anonymization basics, we now tackle k-anonymity, a formal privacy model that quantifies how "hidden in the crowd" each person is.

The Core Idea

K-anonymity means that every record in your dataset is indistinguishable from at least k-1 other records when looking at certain identifying attributes (called quasi-identifiers). If k=5, each person's combination of attributes (like age, ZIP code, gender) appears for at least 5 people in the dataset—making it impossible to single out one individual.

Think of it like hiding in a crowd: if you're wearing a red shirt and you're the only one, you're easily spotted. But if k=10 people wear identical red shirts, an observer can't tell which one is you.

How It Works

You achieve k-anonymity through generalization and suppression:

  • Generalization: Replace specific values with broader categories (age 28 → "25-30", ZIP 10001 → "100**")
  • Suppression: Remove values entirely when generalization isn't enough

For example, if only one person has age=92, ZIP=10001, gender=Female, you might generalize age to "90+" and ZIP to "100**" until at least k people share those attributes.

Why It Matters

K-anonymity gives you a measurable privacy guarantee: "No one can be uniquely identified with confidence better than 1/k." Higher k means stronger privacy (but less data utility). It's widely used in releasing medical records, census data, and research datasets.

Key Takeaway:
K-anonymity ensures privacy by making each record indistinguishable from at least k-1 others through generalization and suppression of quasi-identifiers.