Privacy and sensitive data

Collect less, reduce detail, limit access and keep a record: practical privacy habits for machine-learning projects.

Lesson 65 of 6610 minBeginner

You will learn to

  • Identify personal and sensitive data in a dataset
  • Apply data minimisation and generalisation before training
  • Use roles, private projects and the audit log to control and review access

Before this lesson

Intuition

A model project collects a lot of information about people: who they are, what they bought, where they live. Most of it was given for a purpose, such as delivering an order. Using it to train a model is a new use, and it brings responsibility.

Start with two ideas.

Personal data is any information that relates to an identifiable person. Names and emails are obvious. Less obvious are IDs, device numbers, locations and combinations of ordinary columns: age, postcode and job title together can point to one individual. Sensitive data is personal data whose misuse causes more harm: health, finances, ethnicity, religion, political views, biometrics, data about children. Laws such as the GDPR give such data extra protection, and ask you to have a lawful reason to use it. Ask your legal or privacy team what applies to you; this lesson is practical, not legal advice.

Then four habits, in order of how much they help:

  1. Collect less (data minimisation). Before using a column, ask whether the model really needs it. A column you never load cannot leak.
  2. Reduce detail. Replace exact values by coarser ones: age bands instead of birth dates, the first digits of a postcode, a month instead of a timestamp. Remove direct identifiers such as names and emails before analysis.
  3. Limit access. Only people who need the data should see it, with the least access that lets them work.
  4. Keep a record. Be able to answer "who changed what, and when?"

Removing names is not anonymisation. If a few ordinary columns are enough to single out a person, the data is still personal. A useful check is to count how many rows share each combination of such columns.

Picture it

1Collect lessOnly columns the model needs2Reduce detailBands instead of exact values3Limit accessRoles and private projects4Keep a recordAudit log of changes
Four habits that protect personal data across a project, from least effort and most impact on the left.

The math

Two small ideas are worth knowing.

k-anonymity. Pick the columns that could identify someone when combined (called quasi-identifiers: age, postcode, gender). Group the rows by their values. The smallest group size is kk:

k=min⁡g  ∣{rows with quasi-identifier values g}∣k = \min_{g} \; |\{\text{rows with quasi-identifier values } g\}|

If k=1k = 1, at least one person is unique and can be re-identified by anyone who knows those values. A larger kk means each person hides in a crowd of at least kk look-alikes. It is not a guarantee: if all the rows in a group share a sensitive value (for example, the same diagnosis), the value leaks anyway. Treat k as a quick screening tool.

Generalisation raises k. Coarser values make groups larger, at the cost of detail the model may want. That is the privacy and usefulness trade-off, and you decide it on purpose.

Worked example

A clinic keeps 12 patient rows with two quasi-identifiers: age band and the first three digits of the postcode. (Illustrative data.)

Age bandPostcode prefixRows
30-392823
40-492822
40-491003
50-591004

The smallest group has 2 rows, so k=2k = 2. Two people in the 40-49, 282 group are hard to tell apart from each other but easy to tell from everyone else. A little more generalisation helps. Merge the age bands 30-39 and 40-49 into 30-49:

Age bandPostcode prefixRows
30-492825
30-491003
50-591004

Now k=3k = 3. Before that, with exact ages and full postcodes, almost every row would have been alone, so k=1k = 1. Each step trades a little detail for more protection. Ask whether the model loses anything that matters: if age bands of ten years predict as well as exact ages, the finer detail was only risk.

Another small saving: the clinic's table also had name, email and phone number. None of them help predict the outcome, so they are removed before the data reaches the model. That is data minimisation, and it cost nothing in accuracy.

How mlflow does it

  • Roles. Workspace roles include owner, admin, project admin, ML engineer, data scientist, viewer and service account. Viewer and service accounts are read-only everywhere.
  • Project roles. Within a project, people are viewer, editor or owner. Your effective role in a project follows from your workspace role, any explicit grant and the installation default; read-only workspace roles are capped at viewer.
  • Private projects. An installation can be set so that projects are visible only to their explicit members and to workspace admins, instead of giving every workspace member editor access by default.
  • Secrets. Connection passwords and AI provider keys are stored encrypted. Keys act with the permissions of the person who owns them.
  • Audit log. Every change made through the API (create, update, delete) is recorded with who did it and a payload from which secret-looking fields are removed. Reads are not logged. The installation-wide log is visible to superusers; workspace admins see a log scoped to their workspace.
  • Deployments. Choose the narrowest access mode: Workspace members or API key, not Public, unless the model is meant for anyone.

Remember that mlflow protects who can open data inside the platform. It does not decide whether you may use the data. That remains your responsibility.

Common mistakes

  • Using every available column. More columns means more risk and often little accuracy. Include a column only when you can say why the model needs it.
  • Believing that removing names makes data anonymous. Combinations of ordinary columns can identify people. Check group sizes.
  • Putting real personal data in a shared notebook or screenshot. Copies escape your controls. Use samples or masked values when sharing.
  • Giving broad access "for convenience". Start from the least access and grant more when asked.
  • Forgetting the model itself. Models and predictions can reveal information about their training data. Treat a model trained on sensitive data as sensitive, and avoid public endpoints for it.

Try it in mlflow

Review who can see your project

  1. Open Settings and choose Members.
  2. Read each member's role. Does anyone have more access than their work needs?
  3. Ask your workspace admin whether projects are private by default on this installation (only their explicit members and workspace admins can see them).
  4. Ask your workspace admin where the audit log is, and which changes it records.
Open in mlflow

Read in the docs

Check your understanding

  1. 1. Which of these is personal data?
  2. 2. What does data minimisation mean?
  3. 3. A table has k = 1 for its combination of age and postcode. What does it mean?