DS 227 · Week 11

Ethics & Privacy

In data and analytics: what may be done with what can be done, and how to protect the people in the rows.

Knowledge Discovery in Data · University of the Philippines Cebu

Outline

Ethical limits on the analysis pipeline

Key terms · 1 of 2

Eight terms about the people in the data

personal information (personal data)

Any data that identifies a person, on its own or when combined with other data.

e.g. a name, a student number, or age + barangay + course together

sensitive personal information

Personal information the law protects more strictly: health, education, government IDs, religion…

e.g. a student's GPA is education data, so it is sensitive

PII

"Personally identifiable information": the common industry name for roughly the same idea as personal information.

e.g. email address, phone number, home address

data subject

The person the data is about. The law gives them rights over it.

e.g. the student in row 3 of a class list

consent

A person's clear, informed "yes" to their data being used for a stated purpose.

e.g. ticking "use my answers to evaluate this course"

processing

Anything done with personal data: collecting, storing, analysing, sharing, deleting.

e.g. running a groupby on a class survey is processing

purpose limitation

Data collected for one purpose is used for that purpose only.

e.g. enrolment phone numbers are not a marketing list

data minimisation

Collect and keep only the columns the purpose really needs.

e.g. birth year instead of full birth date

Key terms · 2 of 2

Ten terms for protecting them

direct identifier

A column that names one person by itself.

e.g. student_id, full name, email

quasi-identifier

A column that is harmless alone but can point to one person when combined with others.

e.g. age, barangay, birth date, sex

re-identification

Matching an "anonymous" record back to a real, named person.

e.g. joining a health table to a voter list on ZIP + birth date + sex

k-anonymity

Every combination of quasi-identifiers is shared by at least k records. k = 1 means someone stands alone.

e.g. k = 3: every record shares its combination with at least two others

generalisation

Making a column less precise so more records look alike.

e.g. age 19 → "18–20"; exact budget → ₱50M band

suppression

Withholding any number or row that describes too few people.

e.g. no average published for a group of fewer than 5

anonymisation

Changing data so that nobody in it can be identified, by anyone, any more. Hard to achieve.

e.g. only group totals released, every group large

pseudonymisation

Replacing names with a code. Rows still link together, so it is not anonymous.

e.g. 2024-001 → 3e0f221a8d0c

bias

A systematic tilt in data or analysis, so results lean one way for some group.

e.g. an online survey that misses people without internet

fairness

Whether an analysis or decision treats different groups of people equally well.

e.g. the same error rate for rich and poor barangays

About the tool

Differential privacy was defined in 2006

2006

The definition

Cynthia Dwork, Frank McSherry, Kobbi Nissim and Adam Smith formalise how much noise to add.

2014

Google

RAPPOR collects browser statistics without exposing any one user.

2016

Apple

iOS 10 uses it to learn from phones without reading individual data.

2017

Gödel Prize

The 2006 paper receives a top prize in theoretical computer science.

SourceWikipedia: Differential privacy

About the tool

Where differential privacy is used

SourceUS Census Bureau: Differential privacy; Wikipedia: Differential privacy

Runnable code

Code on these slides runs in the browser

As in earlier weeks, a block with a ▶ Run / Edit button runs in the browser. This week’s small examples use the lab’s four students, so every re-identification can be checked by eye; the flood audits run in the companion notebook.

Templates are not code

Blocks that hold a checklist, a consent statement or a framing to adapt have no Run button and are not part of the notebook.

import io, sys print("pandas version:", pd.__version__) print("64-bit Python:", sys.maxsize > 2**32) t = pd.read_csv(io.StringIO("city,pop\nCebu,964000")) print(t.dtypes) pandas version: 3.0.5 64-bit Python: True city str pop int64 dtype: object
  • pd.__version__the installed pandas: 3.0.5 on the laptop, 2.2.0 in the browser
  • t.dtypeseach column’s type: str on the laptop, object in the browser
Part A

Motivation

Data about people carries risk for them and for the analyst.

Weeks 3–10 covered collecting, cleaning, exploring and presenting data. This part addresses a prior question: what the people in the rows are owed.

Consequences

Consequences of a leaked record

In a notebook, a row is four values. For the person described, it may be a location an abuser should not learn, a diagnosis an employer should not see, or a grade that invites family shame.

Harms are concrete

Stalking, discrimination in hiring or insurance, public humiliation and identity theft are all documented consequences of leaked datasets.

Harms are asymmetric

Publication happens once; the person bears the effects permanently. Released data cannot be fully withdrawn.

Consequence

The burden of care rests on the analyst, the one person who sees the whole table.

Case studies

Three releases that shaped the field

Re-identification cases

Three datasets described as "anonymised"

CaseWhat was releasedHow it was re-identified
Sweeney, 1997State employee health records with names removedZIP + birthdate + sex uniquely identified most people; matched against a public voter roll
AOL, 200620 million search queries, user IDs replaced with numbersThe searches themselves were identifying; journalists traced user 4417749 to a named individual
Netflix Prize, 2006100 million movie ratings, subscriber IDs removedMatched against public IMDb reviews; a handful of dated ratings identified subscribers
Shared lesson

Anonymisation cannot anticipate future datasets

Each release was safe against the data available that day. None survived a join with something that appeared later. (A quasi-identifier, in the code comment, is a column that is harmless alone but identifying in combination; Part B makes it precise.)

Minimisation is more reliable than anonymisation

Data minimisation means collecting only what the purpose needs. A column that was never collected cannot be joined against anything. An "anonymised" column can be, by data that does not yet exist.

# what each team believed "we removed the identifiers" # what was true "we removed the identifiers we thought of, and left a fingerprint that matched a public dataset we had not considered" # your quasi-identifier analysis is # only as good as the outside data # you imagined
Principles

Consent applies to a purpose, not indefinitely

Consent is a person's clear, informed "yes" to a stated use of their data. People provide data for a purpose: enrollment, delivery, a health consultation. Reusing it for another purpose is a new decision that requires its own justification.

Lending a car "to go to the market" does not cover a road trip to Manila, however carefully the borrower drives.

Purpose limitation

Collected for X, used for X. The enrollment form's phone numbers are not a marketing list.

Proportionality

Only the minimum that serves the purpose is collected. Every extra column is additional risk held by choice.

Public ≠ consented

An extension of week 4: a reachable post is not permission to compile a profile. Aggregating public traces creates something new and more dangerous.

Legal framework

RA 10173: the Data Privacy Act of 2012

Philippine law, enforced by the National Privacy Commission. If the rows describe people, this act sets the analyst's obligations.

Words the act uses

data subject
the person the data is about
processing
anything done with personal data: collect, store, analyse, share, delete
NPC
National Privacy Commission, the government office that enforces the act
PII
"personally identifiable information", the industry name for personal information
ConceptMeaning
Personal informationData that identifies a person, alone or combined
Sensitive personal infoHealth, education, government IDs, and more; stricter rules
Data subject rightsTo be informed, to access, to correct, to object
AccountabilityWhoever processes the data answers for its protection

Note on the second row

Education records, such as GPAs, are sensitive personal information under the act. This week's lab dataset is a small example of regulated data.

RA 10173 in detail

Requirements of the Data Privacy Act

The Philippine Data Privacy Act of 2012 is not a general principle; it imposes specific, checkable duties on anyone processing personal data.

It applies to student projects

Scope is about processing personal information, not about being a company. A class survey with names in it is covered.

Personal data is like cash given for one errand, to be used only for that errand, in the amount needed, kept safe, and returned or destroyed afterwards. (This is a summary for analysts, not legal advice.)

• collect for a declared, specific purpose — and only that purpose • collect the minimum needed • keep it accurate and current • retain only as long as the purpose requires, then dispose securely • secure it — organisationally and technically • honour the subject's rights: to be informed, to access, to object, to erasure, to damages
Scope of consent

Consent is not a permanent licence

Consent given for one stated purpose does not extend to later ideas. Re-using data for a new purpose needs a new basis.

The test

Whether the person would have agreed to this use at the moment of consent. If this is uncertain, consent must be sought again.

# what they consented to "to evaluate this course" # what that does NOT cover - publishing quotes with names - sharing with another department - training a model (a prediction program learned from the data) - keeping it after the term ends # each is a new purpose needing # a new basis — usually fresh consent
Review question

Question (select to reveal the answer)

For a study, a researcher scrapes thousands of public social-media posts with usernames and publishes the dataset, arguing that "it was all public." Does that argument hold?

A · Yes — public means fair game
B · Yes, if the scraping was slow and polite
C · No — compiling identified profiles is new processing of personal data, needing its own justification
D · Only lawyers can have an opinion

C: compilation creates something the separate posts were not.

A thousand scattered posts and one searchable dataset of named people are different objects with different risks. Politeness (B) answers the server-load question, not the persons-in-the-data question. At minimum, the data should be de-identified and aggregated, with a known legal basis.

Break

  Five minutes

Next: privacy as a testable engineering problem.

Part B

Privacy engineering

Auditing and reducing risk in pandas.

Weeks 6–7 covered grouping and counting rows (groupby). This part uses the same operation to measure how exposed each record is, and then to reduce that exposure.

Column types

Direct, quasi and sensitive columns

The risk lies not only in the obvious column but also in the combination of apparently harmless columns around it.

# the lab's four students (the lab calls this table df) students = pd.DataFrame({ "student_id": ["2024-001", "2024-002", "2024-003", "2024-004"], "age": [19, 19, 21, 19], "barangay": ["Lahug", "Lahug", "Apas", "Lahug"], "gpa": [1.75, 2.00, 1.25, 1.50], }) print(students) student_id age barangay gpa 0 2024-001 19 Lahug 1.75 1 2024-002 19 Lahug 2.00 2 2024-003 21 Apas 1.25 3 2024-004 19 Lahug 1.50
  • studentsthe lab’s four students (the lab calls this table df; here df is the flood data)
  • student_ida direct identifier: names one person on its own
  • age, barangayquasi-identifiers: harmless alone, identifying together

Classification

student_id: direct identifier, names a person. age, barangay: quasi-identifiers, harmless alone, identifying together. gpa: sensitive, the value to be protected.

Linkage attacks

Identification without a name

"Latanya Sweeney showed that 87% of Americans are uniquely identified by ZIP code, birth date and sex alone, and re-identified the governor of Massachusetts in an 'anonymized' medical dataset using those columns."
Quasi-identifiers + one outside dataset = a name
Exercise · 3 min

k-anonymity: counting group sizes

The rows are grouped by the quasi-identifiers and the group sizes checked. A group of 1 is a person who can be singled out. k-anonymity: a table is "k-anonymous" when every combination appears at least k times.

  • df.groupby(["age", "barangay"])put rows with the same age and barangay in one group
  • .size()count the rows in each group
  • 19 Lahug 3three students share "19, Lahug": each hides among three
  • 21 Apas 1a group of one: that student is exposed, so k = 1

Tasks

  1. Predict the size of each age-and-barangay group.
  2. Select ▶ Run / Edit and run the code.
  3. Group by ["barangay"] only. Is anyone still alone?

Result on the lecture laptop (select to reveal)

(19, Lahug) holds 3 students and (21, Apas) holds 1: k = 1, so student 2024-003 is exposed. By barangay alone, Lahug has 3 and Apas still 1: the barangay by itself identifies her.

# students: the lab's four students sizes = students.groupby(["age", "barangay"]).size() print(sizes)

Interpreting the audit

The 21-year-old from Apas is unique, so anyone who knows those two facts learns that student's GPA. The smallest group is 1, so this table is not 2-anonymous.

Conceptual model

Four students produce two groups, and one group is a single person

4 rows group by age + barangay size · mean gpa k = smallest size 19 · Lahug 2024-001 · gpa 1.75 19 · Lahug 2024-002 · gpa 2.00 21 · Apas 2024-003 · gpa 1.25 19 · Lahug 2024-004 · gpa 1.50 19 · Lahug ×3 3 students mean gpa 1.75 21 · Apas ×1 1 student mean gpa 1.25 k = 1 2024-003 is alone: the group mean 1.25 is that student's gpa
Computation on real data

k-anonymity on 34,079 real records

The effect of one additional column.

Case study

The flood data, audited for re-identification

The same group-size audit, on the 34,079 flood projects: how many projects are alone in their combination of region, province, year and budget?

The browser cannot download the data, so the flood blocks have no Run button; the companion notebook runs them.

import io, requests url = "https://portal.latarak.com/api/flood/export.csv" df = pd.read_csv(io.StringIO(requests.get(url, timeout=60).text)) print(df.shape) (34079, 15)
  • requests.get(url)download the whole table in one request
  • (34079, 15)34,079 projects, 15 columns
Baseline

Region alone identifies no one

Grouped by region, the smallest group has 180 records. No single project can be picked out; every row has at least 179 others that look identical. (These rows are projects, not people; the audit works the same way on either.)

k = 180

The smallest group size is the k. Higher is safer, and 180 is well above common thresholds.

  • len(g)how many groups: 18 regions
  • g.min()the smallest group's size, which is the k
  • (g == 1).sum()g == 1 gives True/False per group; .sum() counts the Trues (True counts as 1)
g = df.groupby(["region"]).size() print(len(g)) # groups print(g.min()) # the smallest group: k print((g == 1).sum()) # rows alone in their group 18 180 0
Adding columns one at a time

Individually harmless columns in combination

Quasi-identifiersGroupsRecords alone (k=1)% unique
region1800.0%
region + year18010.0%
region + province + year1,944960.3%
+ budget rounded to ₱1M16,64610,53430.9%
A reusable audit

Three lines, wrapped in a function

The same audit runs for every column list, so it is wrapped in a function (week 2: a named, reusable piece of work). Each experiment is then one line.

  • def audit(cols):define a function called audit that takes a list of column names
  • alone = (g == 1).sum()how many groups hold exactly one record
  • print(f"{len(g):,} ...")an f-string: :, adds thousands commas, :.1% shows a share as a percentage
  • (df.budget/1e6).round()budget in millions of pesos, rounded: ₱12,345,678 → 12.0
  • 30.9%almost a third of all projects are alone in their group
def audit(cols): g = df.groupby(cols).size() alone = (g == 1).sum() print(f"{len(g):,} groups, {alone:,} alone ({alone / len(df):.1%})") qi = ["region", "province", "year", "b"] # precise: PHP millions df["b"] = (df.budget / 1e6).round() audit(qi) 16,646 groups, 10,534 alone (30.9%)
Generalisation

Generalisation restores privacy

Generalisation means making a column less precise so more records look alike. With the budget column kept in ₱50M bands instead of exact millions, uniqueness falls from 30.9% to 2.7%. With place also generalised (province up to region), it falls to 0.4%.

Precision exchanged for privacy

The exact cost and province of a project are no longer available. Its band and region still are, which is enough for most questions.

In a photo taken from further away, faces blur into a crowd, but the crowd can still be counted and located.

# audit(cols), qi: from the previous slide # generalised: PHP 50M bands df["b"] = (df.budget / 5e7).round() * 50 audit(qi) # and generalise place: region, not province audit(["region", "year", "b"]) 4,675 groups, 915 alone (2.7%) 821 groups, 132 alone (0.4%)
Trade-off

Full precision and full privacy are incompatible

Every generalisation that protects someone also removes something a legitimate analysis could have used. Ignoring this trade-off leads to poor results on both.

Deciding by the question

For an analysis of regional totals, ₱50M bands cost nothing. For a study of cost variation within a province, they remove the needed detail, so a different protection is required, not a different rounding.

# the honest framing precision ────────────► privacy exact values wide bands, by province by region 30.9% unique 0.4% unique any analysis aggregate only pick the LEAST generalisation that gets k above your threshold — not the most you can get away with
Worked example

Dropping direct identifiers and generalizing quasi-identifiers

student_id is removed outright. The quasi-identifiers are then made less precise (exact age becomes an age band), so the groups grow.

  • drop(columns=["student_id"])remove the direct identifier
  • pd.cut(safe["age"], bins=[17, 20, 25], …)replace exact age with a band: 18–20 or 21–25
  • drop(columns=["age"])and drop the exact age itself
# students: the lab's four students safe = students.drop(columns=["student_id"]) safe["age_band"] = pd.cut(safe["age"], bins=[17, 20, 25], labels=["18-20", "21-25"]) safe = safe.drop(columns=["age"]) print(safe) barangay gpa age_band 0 Lahug 1.75 18-20 1 Lahug 2.00 18-20 2 Apas 1.25 21-25 3 Lahug 1.50 18-20

Effect of generalization

"19, Lahug" and "20, Lahug" merge into "18–20, Lahug": one larger group instead of two small ones. Larger k, lower risk, same broad analytical shape.

Cost of protection

Privacy and precision pull against each other

Bands lose detail: a study of "GPA by exact age" is impossible when age becomes two bins. That loss is the cost of protection, and someone must decide how much is acceptable.

Too little generalization

Risk remains; the k=1 cells persist under new labels.

Too much generalization

The dataset becomes safe but analytically useless.

Responsibility for the threshold

Not the analyst alone. Purpose, audience and the data subjects' interests all matter, which is why review processes exist.

Exercise · 3 min

A mean over one record reveals that record

A raw table would not be published, but a summary table appears safe. The counts show that the "average GPA in Apas" is one specific student's GPA.

  • df.groupby("barangay")["gpa"]group the students by barangay and look at the gpa column
  • .agg(["mean", "count"])two summaries per group: the average and how many students
  • \ at the end of a line"this line continues on the next one"
  • 1.25, 1an average over one student: it is that student's GPA

Tasks

  1. Predict Apas’s mean GPA, and what it reveals.
  2. Select ▶ Run / Edit and run the code.
  3. Add .query("count >= 2") to the end. What is published now?

Result on the lecture laptop (select to reveal)

Apas: mean 1.25 over 1 student, which is that student’s exact GPA. With the threshold only Lahug remains (mean 1.75, 3 students): the cell of one is suppressed, as statistical agencies do.

# students: the lab's four students print(students.groupby("barangay")["gpa"].agg(["mean", "count"]))

The suppression rule

Suppression means withholding any number that describes too few people. Statistical agencies suppress any cell below a minimum count (often 3–10) for exactly this reason. The rule: no statistic for a group smaller than the threshold.

Small cells

The smallest real cell in this dataset

Cordillera Administrative Region, 2026: one project. Publishing "the average project in CAR in 2026 cost X" publishes that single contract’s exact value.

  • c.nsmallest(3)the three smallest counts; a blank region means “same as the row above”
  • safe = c[c >= 5]keep only cells with 5 or more records: suppression
  • (180, 179)180 cells before, 179 after: one cell was withheld

Aggregation is not automatically anonymisation

A statistic over a group of one is the individual. Over a group of two, either party can subtract its own value and recover the other.

c = df.groupby(["region", "year"]).size() print(c.nsmallest(3)) # suppress cells below a threshold safe = c[c >= 5] print(len(c), len(safe)) region year Cordillera Administrative Region 2026 1 Central Office 2024 6 2020 13 dtype: int64 180 179
Publishing aggregates

Three rules used by statistical agencies

Exercise · 3 min

A solution to the repeated-query problem

Suppression stops one bad query. It does not prevent two overlapping queries being subtracted. Differential privacy addresses this directly: it adds a little random noise to every answer.

In a survey where each person privately flips a coin before answering, no single answer is reliable, so no one is exposed, yet the overall percentage remains close.

The guarantee, in words

Each answer is almost exactly as likely whether or not any single record is in the dataset. So the answer cannot reveal that record.

Tasks

  1. Predict which privacy budget (eps) gives the noisiest answers.
  2. Select ▶ Run / Edit and run the code.
  3. Change size=3 to size=1000 and print noisy.mean().round(1). What happens to the noise?

Result on the lecture laptop (select to reveal)

eps = 0.1: answers spread from about 1238 to 1266; at eps = 10 they stay within 0.1 of 1263. Averaged over 1,000 answers the noise cancels (1263.5, 1262.9, 1263.0): repeated queries leak the truth, which is why the budget must be spent, not reset.

import numpy as np rng = np.random.default_rng(0) true_count = 1263 # revoked-firm projects (week 9) for eps in [0.1, 1.0, 10.0]: # the privacy budget per query noisy = true_count + rng.laplace(scale=1 / eps, size=3) print(eps, noisy.round(1))
  • laplace_noise(scale=1/eps)a stand-in name, not a real pandas function: "a random number, usually small, positive or negative"
  • epsepsilon, the privacy budget: how much each answer may reveal
  • noisythe published number, e.g. 1,261 or 1,265 instead of exactly 1,263
Choosing a protection

Three protections, three situations

Hashing

Hashing hides the name, not the person

Hashing turns any text into a fixed-length scramble of characters (a digest); SHA-256 is one standard recipe. Replacing student_id with its digest keeps rows linkable across files without showing the id. This is useful, but it is pseudonymisation (a code instead of a name), not anonymisation.

import hashlib print(hashlib.sha256(b"2024-001").hexdigest()[:12]) 3e0f221a8d0c

The b before the quotes turns the text into bytes, which hashing needs; [:12] keeps the first 12 of 64 characters.

A pseudonym is a nickname that hides the name, but activity under the nickname still links together, and anyone with the list of nicknames can reverse it.

Why it is not anonymity

The same input always gives the same hash, so anyone who can guess the id space (for example, a four-digit year plus three digits) can hash every candidate and match.

Linkability persists

A stable pseudonym exists so that rows still connect, and that connection is what re-identification attacks exploit.

Legal status

Pseudonymized data is still personal data under privacy law, and the obligations remain.

Review question

Question (select to reveal the answer)

student_id was removed before the class dataset was published. A classmate says it is now anonymous. Is it?

A · Yes — no id, no identification
B · Not necessarily — quasi-identifier combos with k=1 can still single people out
C · Yes, if the file is renamed "anonymous.csv"
D · Anonymity is impossible, so publish anything

B: the audit comes before the claim.

"We removed the names" is where AOL and Netflix started, too. The quasi-identifiers are grouped, the k=1 cells found, and values generalized until the groups are large enough; only then can anonymity be claimed, with care. (D is not an argument.)

Part C

Beyond privacy

Bias, transparency, and self-applied tests.

Part B covered measuring and reducing the risk to the people in a table. This part addresses wider questions: who the data leaves out, and whether the analysis is fair to them.

Bias

Data reflects existing inequities

Mechanisms of bias

Correction requires identifying the mechanism

"The data is biased" is not a finding. How the bias entered determines whether and how it can be corrected.

Three distinct mechanisms

They need different fixes: reweighting (counting under-represented rows more heavily), better collection, or abandoning the question. Conflating them produces confident, wrong corrections.

Weighing only the people who came to the gym is selection bias. A bathroom scale that always reads 2 kg light is measurement bias. Both give a wrong average, for different reasons.

# 1. SELECTION — who got in only completed projects have a duration -> your "typical project" excludes everything that stalled # 2. MEASUREMENT — how it was recorded amount_paid is never populated -> any "unpaid" analysis is an artifact of the recording process # 3. HISTORICAL — the world was unfair past allocation patterns encode past priorities; a model fit on them reproduces those priorities
Decision framework

Four questions before collection, retention or publication

QuestionResponse to an unfavourable answer
Should this exist? What is the purpose, and does this dataset serve it?The data is not collected. Minimisation is the only protection that cannot fail.
Who is exposed? k computed on the quasi-identifiers.Generalisation until k clears the threshold, with the cost recorded.
Who bears the risk? Is it the same people who get the benefit?If the subjects carry the risk and others take the benefit, that asymmetry needs explicit justification.
What if the claim is wrong? Who is harmed by a false claim here?A correspondingly higher evidence threshold. Named parties need more than aggregates do.
Professional tests

Three tests before collection, retention or publication

They are quick to apply and identify most problems early.

  The front-page test

Whether the methods, described accurately on a front page, could be defended rather than explained away.

  The row-3 test

Whether the analyst could describe directly to the person in row 3 what was done with their data.

  The hesitation test

A need to construct a justification is itself the answer. A supervisor, an ethics board or the NPC's guidance should be consulted before, not after.

Public data and harm

This dataset names real companies

There is no personal privacy question here: the data concerns public money and corporate entities. That does not make publication risk-free.

Different harm, same care

A false claim about a named firm is defamation (a false public statement that harms a reputation) rather than a privacy breach, but the obligation to get it right is identical.

# the week 9 example, as an ethics case 131 contractors carry "[REVOKED]" 1,263 projects, PHP 75.2B The data supports: "flagged licence-revoked in the DPWH export" The data does NOT support: "awarded contracts while their licence was revoked" — there is no revocation date.
Minimising collection

The safest record is one never stored

Every field kept can leak, be subpoenaed (ordered handed over by a court), or be re-identified later by data that does not exist yet. A retention period is how long data is kept before deletion.

The question at collection time

Which analysis needs this column. If none does, it is not collected. Retro-fitting privacy is far harder than not collecting.

# do you need... exact birthdate? -> birth year full address? -> barangay exact coordinates? -> municipality name + email? -> a random id free-text comments? -> often not # and set a retention period at the # same moment you create the field
Deletion

Four places where deleted data persists

LocationWhy it survives a deleteResponse
BackupsRestore points predate the deletion — by designRetention window known; deletions timed against it
Derived tablesAggregates and exports built before the deleteLineage tracked: the outputs that used this input
Version controlA committed file lives in history foreverData never committed, since a later delete does not remove it
Other people’s copiesAnything shared or downloadedA log of who received what, and when
Exercise · 8 min

Re-identification and protection

1 · Reproduce the progression

Compute group sizes for region; then region+year; then +province; then +budget rounded to the million. Count k=1 groups at each step.

2 · Find a further quasi-identifier

Identify the single extra column that raises uniqueness most, and explain why.

3 · Generalise it back

Widen the band until fewer than 1% of records are unique. State the resolution lost.

4 · Write the release note

Two sentences: what was generalised, and which analyses remain valid on the released version.

Review question

Question (select to reveal the answer)

Grouping by region gives a minimum group size of 180. Province, year, and budget rounded to the nearest million are added. What happens?

A · Little changes — rounded budgets are not identifying
B · 30.9% of records become uniquely identifiable
C · Privacy improves, because the groups are more specific
D · It has no effect unless names are also included
B. Measured: 16,646 groups, 10,534 of them containing a single record — from 0 singletons with region alone. No individual column here is identifying; the combination is. That is precisely what a quasi-identifier is, and why privacy review has to consider column sets rather than columns.
Review question

Question (select to reveal the answer)

Mean project cost is published per region-year. One cell (Cordillera, 2026) contains a single project. What has been published?

A · An aggregate, which is inherently anonymous
B · That project’s exact cost — a mean over one record is the record
C · Nothing sensitive, since it is public spending data
D · A biased estimate, but nothing identifying
B. Aggregation protects only when the group is large enough to hide in. A mean over n=1 is the value itself; over n=2, either party can subtract their own and recover the other. This is why agencies suppress small cells, and why a second cell must also be suppressed, or the total reveals the first by subtraction.
This week's lab

Auditing a dataset for privacy risk

Four students, one sensitive column. The lab classifies the identifiers, finds the k=1 group, fixes it by dropping and banding, and identifies a leaking aggregate. ~45 minutes.

Lab tasks

Identifier triage, groupby().size() as a k-anonymity audit, pd.cut age bands, and count-based suppression.

Optional extension

Hash an id with hashlib.sha256 and argue pseudonymous-vs-anonymous; find the riskiest quasi-identifier combination.

Summary

Four main points

Glossary

This week's terms, one line each

Key terms

personal information (personal data)
data that identifies a person, alone or combined
sensitive personal information
health, education, IDs…: stricter rules
PII
personally identifiable information (industry term)
data subject
the person the data is about
consent
an informed "yes" to one stated use
processing
anything done with personal data
purpose limitation
collected for X, used for X only
data minimisation
collect and keep only what the purpose needs
direct identifier
a column that names a person by itself
quasi-identifier
harmless alone, identifying in combination
re-identification
matching an "anonymous" row to a named person
k-anonymity
every combination shared by at least k records
generalisation
less precise values so more rows look alike
suppression
withholding numbers about too few people
anonymisation
nobody can be identified, by anyone, any more
pseudonymisation
a code instead of a name; rows still link
bias
a systematic tilt for or against some group
fairness
treating different groups equally well

Also new today

RA 10173
the Philippine Data Privacy Act of 2012
NPC
National Privacy Commission, which enforces it
data subject rights
to be informed, access, correct, object…
sensitive (column)
the value worth protecting, e.g. GPA
aggregate
a summary over a group: total, average
differential privacy
small random noise added to every answer
hashing / digest
a fixed scramble of text; same input, same output
proxy
a column that stands in for another
selection / measurement bias
who got in / how it was recorded
retention period
how long data is kept before deletion
defamation
a false public claim that harms a reputation
lineage
which outputs were built from which inputs
Readings

Preparation for next week

Next week

Course synthesis

The whole KDD process in one view, followed by the final presentations.

DS 227 · Knowledge Discovery in Data