license: mit
pretty_name: Anonymization Before/After
size_categories:
- n<1K
language: - en
task_categories: - tabular-classification
- tabular-regression
- other
tags: - privacy
- anonymization
- k-anonymity
- synthetic-pii
- tabular
- teaching
- benchmark
- red-team
configs: - config_name: raw
data_files: sample_raw.csv - config_name: anonymized
data_files: sample_anonymized.csv
Anonymization Before/After
A small paired tabular dataset showing the same records before and after
a 10-step anonymization pipeline. Useful as a teaching fixture for privacy
courses, a benchmark for anonymization toolkits, and a sanity-check input
for red-team / membership-inference experiments.
Important: the PII in
sample_raw.csvis entirely synthetic.
Names follow the patternPerson_001, emails are[email protected],
phone numbers are555-00XX, and "national IDs" are random 9-digit strings.
No real individual is represented. The dataset is published precisely so
researchers can demonstrate privacy techniques on PII-shaped data without
handling real PII.
At a glance
raw |
anonymized |
|
|---|---|---|
| Rows | 500 | 339 |
| Columns | 16 | 10 |
| Direct identifiers | ✅ present (4) | ❌ dropped |
| Fingerprint columns | ✅ present (2) | ❌ dropped |
| Quasi-identifiers | exact values | generalised (bands / top-N / "Other") |
| Numeric fields | exact values | multiplicative noise injected |
| Dates | exact dates | HMAC-perturbed ±7 days |
| k-anonymity (over age/region/gender) | k=1 in many groups | k≥5 (rest suppressed) |
The 161 missing rows in anonymized were suppressed during k-anonymity
enforcement: every combination of (age band, region, gender) appears at
least 5 times in the released data.
What changed, column by column
| Raw column | Action | Anonymized column |
|---|---|---|
full_name |
dropped (direct ID) | - |
email |
dropped (direct ID) | - |
phone_number |
dropped (direct ID) | - |
national_id |
dropped (direct ID) | - |
source_system_code |
dropped (fingerprint) | - |
internal_batch_id |
dropped (fingerprint) | - |
age (int) |
banded into 10-year ranges | age (e.g. "50 - 60") |
region (str) |
rare categories collapsed to "Other" (top-6 kept) |
region |
gender (str) |
passthrough | gender |
marital_status (str) |
passthrough | marital_status |
income (float) |
±5% multiplicative noise, rounded to 2dp | income |
balance (float) |
±3% multiplicative noise, rounded to 2dp | balance |
credit_score (int) |
passthrough | credit_score |
transaction_amount (float) |
passthrough | transaction_amount |
created_date (date) |
HMAC-deterministic ±7-day offset | created_date |
last_login_date (date) |
HMAC-deterministic ±7-day offset | last_login_date |
After all transforms, columns in the anonymized split are sorted
alphabetically and rows are deterministically shuffled (seed=42).
How to use
from datasets import load_dataset
raw = load_dataset("t22000t/anonymization-before-after", "raw", split="train")
anon = load_dataset("t22000t/anonymization-before-after", "anonymized", split="train")
print(raw[0])
# {'full_name': 'Person_001', 'email': '[email protected]', ...,
# 'age': 51, 'region': 'Northeast', 'income': 40617.24, ...}
print(anon[0])
# {'age': '50 - 60', 'region': 'Other', 'income': 100899.98, ...}
Or plain pandas:
import pandas as pd
raw = pd.read_csv("hf://datasets/t22000t/anonymization-before-after/sample_raw.csv")
anon = pd.read_csv("hf://datasets/t22000t/anonymization-before-after/sample_anonymized.csv")
Suggested uses
- Teaching privacy concepts. The before/after diff makes k-anonymity,
QI generalisation, and direct-ID suppression concrete in a single
side-by-side view. - Benchmarking anonymization toolkits. Re-run a different tool on
rawand compare its output toanonymized(or to your own
adversarial baseline). - Red-team / membership-inference fixtures. Train an MIA classifier
to separaterawfromanonymized; the AUC quantifies how much
identifying signal survived the pipeline. - Sanity-checking a synthetic-data generator. Use
rawas the
target distribution and compare against the generator's output on the
same schema.
How it was produced
sample_raw.csv is generated byscripts/create_sample_data.py
in the data-anonymization-toolkit
repo (seed=42, deterministic).
sample_anonymized.csv is the output of running the toolkit's full
10-step pipeline on raw with the configconfig/example_simple_anonymization.yaml
(profile ml, k_target=5).
Reproduce locally:
git clone https://github.com/timothy22000/data-anonymization-toolkit
cd data-anonymization-toolkit
pip install -e .
python scripts/create_sample_data.py
python scripts/anonymize_data.py \
--input data/sample.csv \
--output data/anonymized.csv \
--config config/example_simple_anonymization.yaml
Limitations and caveats
- Small. 500 rows is enough to demonstrate the pipeline behaviour but
not enough for serious statistical evaluation of a generator. - Synthetic PII. Names, emails, IDs are templated, not realistic.
Adversarial fingerprinting attacks that exploit real-world string
distributions (e.g. uncommon surnames) won't find anything interesting
here. Use a realistic synthetic-PII library (Faker, mimesis) if that
matters for your research. - One profile, one config. Only the
mlprofile (k=5) is provided.
Thepublicprofile (k=20, stronger generalisation) would suppress
many more rows. - The "Other" category dominates
region. Because the toy generator
uses 8 regions but top-N keeps only 6, two regions get collapsed to"Other"in the anonymized split. Real-world QI generalisation is
usually more nuanced.
Personal and sensitive information
None. All PII-shaped fields are deterministically generated from row
indices. No real individual's data was used to create this dataset.
Citation
If you use this dataset in a paper or tutorial, please cite the toolkit
it came from:
@software{data_anonymization_toolkit,
author = {Mun, Timothy},
title = {data-anonymization-toolkit: Config-driven anonymization,
synthetic data, and red-team validation for tabular data},
url = {https://github.com/timothy22000/data-anonymization-toolkit},
year = {2026}
}
License
MIT - see the parent toolkit repo for the full license text.
Related
- 🔒 Privacy Lab Space - interactive anonymization + red-team demo (uses this dataset as the bundled sample)
- 🛡️ Synthetic Data Privacy Audit Space - upload real + synthetic CSVs, get a privacy verdict
- 📦 data-anonymization-toolkit - the underlying Python library