Ethical AI · Advanced level

Advanced level · Module 6: Data Governance and Privacy Risk Assessment · Lesson 3 of 3

Measuring Re-identification Risk

Learners measure re-identification risk with k-anonymity-style group-size checks in pandas, reduce risk through generalisation and suppression, and set rules for sharing data with partners.

In this lesson you will

  • Compute the smallest group size on quasi-identifiers with pandas
  • Reduce re-identification risk before sharing

Key concepts

quasi-identifiersk-anonymitygeneralisationsuppressiondata sharing agreement

The lesson

A dataset is k-anonymous on a set of quasi-identifiers when every combination of their values appears at least k times. In pandas, df.groupby(quasi_identifiers).size().min() gives the smallest group, and counting the groups below k shows how many records are at risk.

Generalisation (exact age to an age band, school to county) and suppression (removing rare records or values) increase k. Each step loses some detail, so check that the data is still useful for its purpose.

k-anonymity does not protect against every attack. For example, if everyone in a group has the same sensitive value, that value is revealed. Combine it with access control and a data sharing agreement that states the purpose, the permitted users, a ban on re-identification, security requirements and deletion.

Step by step

  1. Choose the quasi-identifiers in the capstone dataset.
  2. Compute the minimum group size and count the records in groups smaller than 5.
  3. Generalise and suppress until k is at least 5, and record the information lost.
  4. Draft the key clauses of a data sharing agreement.

Practice activity

Produce a de-identified sharing extract of the capstone data with a k-check report and draft sharing clauses.

Expected result: An extract with k of at least 5 on the chosen quasi-identifiers, a documented record of the information lost and appropriate draft clauses.

Check your understanding

  1. How do you find the smallest group size in pandas?

    Show answer

    df.groupby(quasi_identifiers).size().min().

  2. Why is k-anonymity not enough on its own?

    Show answer

    Groups can still reveal sensitive values when they are all the same, so access control and agreements are also needed.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.