Masking, redaction, and anonymization

Lesson 5 of 5 in Transforming Data and Engineering Features.

PII inside training data is a double liability: models can memorize and regurgitate it, and regulations punish its careless spread. Four verbs the exam expects you to keep straight: masking hides characters in place (****-**34); redaction removes or replaces the value entirely ([NAME]); pseudonymization swaps identity for a consistent token, reversible with a key — records still join across tables; anonymization removes identifiability irreversibly (generalization, aggregation). Choose by downstream need: must you re-link records later? Pseudonymize. Will the data feed a model or leave the trust boundary? Redact or anonymize.

Where each privacy service earns its keep
ServiceWhere it looksWhat it doesUse it when

Amazon Macie

S3 buckets

ML-driven discovery and classification of sensitive data; findings, inventory, continuous monitoring

You must find where PII lives across the lake before anyone trains on it

Amazon Comprehend

Text you send it (real-time or batch)

Detects PII entities with locations; can redact; also offers toxicity detection

Scrubbing free text — transcripts, tickets, corpora headed for fine-tuning

Glue sensitive data detection

Rows flowing through a Glue job

The Detect PII transform finds entities and masks, hashes, or tags them in-pipeline

Redaction should be a standing step of the ETL, not an afterthought

The PII gauntlet

  1. Raw data with PII
  2. Detect

    Macie inventories S3 at bucket scale; Comprehend locates PII entities in text; Glue's Detect PII transform scans rows mid-pipeline.

  3. Classify findings

    Which entity types, which columns, which objects — classification decides severity and the right treatment.

  4. What does downstream need?

    The fork is set by the downstream requirement: values whose shape must survive, text headed for a model, or records that must still join later.

  5. Mask

    Hide characters in place (****-**34). The value's shape survives; the identity does not.

  6. Redact

    Remove or replace entirely ([NAME]) — the default for text headed into embeddings or fine-tuning.

  7. Pseudonymize

    Consistent keyed tokens: the same customer maps to the same token everywhere, reversible under controlled access — joins keep working.

  8. Safe training corpus

    Scrubbed before indexing or training — embeddings and fine-tuned weights are not redactable after the fact.

Key terms: Amazon Macie

Interactive checkpoint quiz (2 questions) — open this page in a browser to take it.