kanon

How it works, and what it cannot tell you

kanon groups the records of a table by the columns an outsider might already know, then measures how small and how uniform those groups are. These are the standard measures from the privacy literature. They tell you a lot about one kind of risk and nothing about several others.

1. Quasi-identifiers and equivalence classes

Removing names and ID numbers does not make a table anonymous. Ordinary attributes such as age, postcode and sex are each harmless, but together they often point at one person. Sweeney called such combinations quasi-identifiers, and showed that a hospital discharge file with no names could be linked to a public voter list on ZIP code, birth date and sex, re-identifying a state governor's medical records. Her estimate was that those three attributes alone were likely to single out about 87% of the US population (Sweeney 2000, cited in Sweeney 2002).

What counts as a quasi-identifier depends on who might attack the data and what else they hold. That choice is yours, not the tool's: kanon suggests columns whose names look like the usual suspects (age, birth date, postcode, sex, nationality, dates), and every number on the results page is only as good as that choice.

Records that share the same values on every quasi-identifier form an equivalence class. If you know a person's quasi-identifier values, you can narrow them down to their class but no further.

2. k-anonymity

A table is k-anonymous when every equivalence class holds at least k records, so each person hides among at least k−1 others with the same visible attributes (Sweeney 2002). kanon reports k as the size of the smallest class. It also reports how many records are unique (a class of one), and the share of records in classes smaller than 2, 5 and 10. k on its own is a worst case; those shares show how widespread the problem is.

RaceBirthGenderZIPProblem
Black1965m0214*short breath
Black1965m0214*chest pain
Black1965f0213*hypertension
Black1965f0213*hypertension
… 7 more rows in the paper
Sweeney's 2-anonymous example (2002, Figure 2). Load it from Examples from the papers on the main page: kanon reports k = 2, no unique records, and a highest re-identification risk of 50%.

3. l-diversity

k-anonymity protects against which row is yours, not against what your row says. Machanavajjhala and colleagues (2007) described two attacks on a k-anonymous table:

A class is distinct l-diverse when it contains at least l different sensitive values. Entropy l-diversity is stricter: the class's sensitive values must be spread evenly enough that their entropy is at least log(l). kanon reports both as the worst class: the smallest number of distinct values, and the smallest value of exp(entropy), which you can read as the number of equally likely values the class is worth. It also counts the records that sit in classes with a single sensitive value.

On the paper's 3-diverse table (Figure 3) kanon reports k = 4, distinct l = 3 and entropy l = 2.83: each class has one value twice and two values once, which is worth less than three equally likely values.

4. t-closeness

l-diversity still leaks when the different values are similar, or when a class's mix is very different from the population's. Li, Li and Venkatasubramanian (2007) give a 3-diverse table in which one class has salaries of 3k, 4k and 5k and only stomach diseases: three distinct values, yet an attacker learns that the person is low-paid and has a stomach condition.

t-closeness asks that the distribution of the sensitive attribute in every class be within distance t of its distribution in the whole table. The distance is the Earth Mover's Distance: the least amount of probability mass that must be moved, times how far it moves, to turn one distribution into the other. For categories every move costs the same (equal distance); for numbers a move between neighbouring values costs less than a move across the range (ordered distance). kanon reports the largest distance over all classes. In the paper's example the low-salary class is 0.375 away from the whole table; after re-grouping, no class is more than 0.167 away. kanon reproduces both numbers.

There is no agreed safe value of t. Smaller is closer to the overall distribution, so less is learned from class membership, but also less of the relationship between quasi-identifiers and the sensitive attribute survives for analysis.

5. Prosecutor, journalist and marketer risk

These three re-identification risk measures describe three attackers (El Emam & Dankar 2008). kanon computes them the way the open-source ARX tool does (Prasser et al. 2020). A record in a class of size f has a 1/f chance of being matched correctly by someone who knows its quasi-identifiers.

The colours mark the chosen threshold: red where some records exceed it, amber where classes are within twice the threshold size, green beyond that. Green means "lower", not "safe".

6. Generalisation and suppression

The usual way to raise k is to make values coarser (generalisation) or withhold some of them (suppression). kanon offers the common ones and recomputes after each change:

Each step costs information. Bands of 10 hide age effects inside the band; dropping rare values removes exactly the small groups that some studies need. ARX and similar tools search for the generalisation that loses the least; kanon only lets you try them by hand and see the effect.

7. Limits, and GDPR

A k value is not a guarantee. It is a statement about one table, one choice of quasi-identifiers and one kind of attack.

Under the GDPR, data are anonymous only when a person is no longer identifiable by any means reasonably likely to be used, by the controller or by anyone else, taking into account cost, time and available technology (Recital 26). Pseudonymised data, such as a table with names replaced by codes, are still personal data. The Article 29 Working Party's Opinion 05/2014 on anonymisation techniques (WP216) asks three questions of any technique: can a person still be singled out, can records be linked across datasets, and can information about a person be inferred? Its assessment is that k-anonymity prevents singling out but leaves linkability and inference risks, that l-diversity and t-closeness reduce the inference risk, and that linkability remains a risk for all three.

An anonymisation decision therefore needs more than this page: a documented assessment of who could attack and with what, the context of the release (public, contract-bound, enclave), the residual risk you accept and why, a review when circumstances change, and usually your data protection officer's or a lawyer's view. kanon gives you numbers for one part of that assessment. It is not legal advice.

8. How the numbers are computed

For n records in classes of size f1 … fc (after suppression), with population sizes Fj (equal to fj without a population), and a sensitive attribute whose overall distribution is Q:

k = min f_j unique records = number of records with f_j = 1 prosecutor highest = 1 / min f_j prosecutor at risk = (1/n) · Σ f_j over classes with 1/f_j > threshold prosecutor average = c / n journalist highest = 1 / min F_j journalist at risk = (1/n) · Σ f_j over classes with 1/F_j > threshold journalist average = max( c / Σ F_j , (1/n) · Σ f_j / F_j ) marketer = (1/n) · Σ f_j / F_j distinct l = min over classes of the number of different sensitive values entropy l = min over classes of exp( −Σ p·ln p ) t (equal distance) = max over classes of ½ · Σ_i |p_i − q_i| t (ordered distance) = max over classes of (1/(m−1)) · Σ_i |Σ_{j≤i} (p_j − q_j)|, values sorted, m values

Q is the distribution of the sensitive attribute over all released rows before record suppression. Blank cells are treated as a value of their own. The risk formulas follow ARX's RiskModelSampleSummary; the t-closeness formulas follow Li et al. (2007), section 4. Everything runs in a Web Worker in your browser: the file is dictionary-encoded once, each generalisation is applied once per distinct value, and classes are found with an integer hash, which is why 200,000 rows take well under a second to analyse.

9. How it was checked

The engine the page uses (kanon.js) is tested against things that are not itself:

Configuration (Adult unless noted)kUniqueProsecutor avg.ltARX
age, sex, race, marital status15635.44%10.995agrees
same, age in bands of 101641.04%10.995agrees
6 QIs, age/5, rare countries → *12,44213.50%10.759agrees
age/10, sex, race, country; suppress < 5500.79%20.868agrees
age/10, sex → occupation1400.06%60.505agrees
education, sex → income1600.10%10.546agrees
synthetic, 200,000 rows, 6 QIs121,74121.66%10.848agrees

Seven of the eleven configurations; the full set, with journalist and marketer risk for a 20% released sample, is in the test results of the source.

10. What this page sends

Your file is read with the browser's File API into a Web Worker in this tab. Nothing from it is uploaded, stored on a server or sent to a third party; there is no server-side code. The page loads its own scripts and styles and two fonts from Google Fonts. It sends three one-word usage signals, load, analyse and export, at most once each per visit, to count how often the tool is used. They carry no data from your file. The built-in sample is synthetic: a script generated every row, and it describes no real people.

11. References

  1. Sweeney L. k-anonymity: a model for protecting privacy. International Journal of Uncertainty, Fuzziness and Knowledge-Based Systems. 2002;10(5):557–570. doi:10.1142/S0218488502001648
  2. Sweeney L. Simple demographics often identify people uniquely. Carnegie Mellon University, Data Privacy Working Paper 3, 2000.
  3. Machanavajjhala A, Kifer D, Gehrke J, Venkitasubramaniam M. l-diversity: Privacy beyond k-anonymity. ACM Transactions on Knowledge Discovery from Data. 2007;1(1):3. doi:10.1145/1217299.1217302
  4. Li N, Li T, Venkatasubramanian S. t-Closeness: Privacy beyond k-anonymity and l-diversity. IEEE 23rd International Conference on Data Engineering (ICDE). 2007:106–115. doi:10.1109/ICDE.2007.367856
  5. El Emam K, Dankar FK. Protecting privacy using k-anonymity. Journal of the American Medical Informatics Association. 2008;15(5):627–637. doi:10.1197/jamia.M2716
  6. Prasser F, Eicher J, Spengler H, Bild R, Kuhn KA. Flexible data anonymization using ARX—Current status and challenges ahead. Software: Practice and Experience. 2020;50(7):1277–1304. doi:10.1002/spe.2812. Source: github.com/arx-deidentifier/arx
  7. Prasser F, Kohlmayer F. Putting statistical disclosure control into practice: the ARX data anonymization tool. In: Medical Data Privacy Handbook. Springer; 2015:111–148. doi:10.1007/978-3-319-23633-9_6
  8. Rocher L, Hendrickx JM, de Montjoye YA. Estimating the success of re-identifications in incomplete datasets using generative models. Nature Communications. 2019;10:3069. doi:10.1038/s41467-019-10933-3
  9. Ganta SR, Kasiviswanathan SP, Smith A. Composition attacks and auxiliary information in data privacy. Proceedings of the 14th ACM SIGKDD. 2008:265–273. doi:10.1145/1401890.1401926
  10. Dwork C. Differential privacy. ICALP 2006, Lecture Notes in Computer Science 4052:1–12. doi:10.1007/11787006_1
  11. Regulation (EU) 2016/679 (General Data Protection Regulation), Recital 26 and Article 4(5). eur-lex.europa.eu/eli/reg/2016/679/oj
  12. Article 29 Data Protection Working Party. Opinion 05/2014 on Anonymisation Techniques (WP216), adopted 10 April 2014.
  13. Becker B, Kohavi R. Adult [dataset]. UCI Machine Learning Repository, 1996. CC BY 4.0. doi:10.24432/C5XW20