suda
Sample uniqueness scoring in Python
This is a Python library for computing sample uniques scoring using the Special Uniques Detection Algorithm (SUDA).
The algorithm looks for rows in a dataset which are unique with respect to a number of category fields and scores them according to risk.
The smaller the number of fields for which a row is unique, the higher the score. So a row which has a unique value for a single field will score highly.
The more combinations by which a row is unique the higher the score. So a row which is unique in multiple ways will score highly.
Usage
Python
Call the suda() method with the dataframe to score, the maximum MSU to test for, the DIS score for the file (defaults to 0.1) and the columns to use for scoring (defaults to all columns).
For example, calling:
results = suda(data, max_msu=2)
Will score the 'data' dataframe and find MSUs of up to two fields. If the dataframe contained fields 'gender', 'age', 'education' and 'employment' then the algorithm will look for rows that are unique for all combinations of one and two fields (gender, age, education, employment, gender & age, gender & education, gender & employment, age & education, age & employment, education & employment.)
The output may look like:
| id | msu | suda | fK | fM | gender | region | education | employment | dis-suda |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.0 | 0.0 | 2.0 | 0.0 | female | urban | secondary incomplete | employed | 0.000000 |
| 1 | 0.0 | 0.0 | 2.0 | 0.0 | female | urban | secondary incomplete | employed | 0.000000 |
| 2 | 1.0 | 12.0 | 1.0 | 4.0 | female | urban | primary incomplete | non-LF | 0.020690 |
| 3 | 0.0 | 0.0 | 2.0 | 0.0 | male | urban | secondary complete | employed | 0.000000 |
| 4 | 1.0 | 16.0 | 1.0 | 6.0 | female | rural | secondary complete | unemployed | 0.027586 |
| 5 | 0.0 | 0.0 | 2.0 | 0.0 | male | urban | secondary complete | employed | 0.000000 |
fK is the minimum frequency of the row -
if this is >1 then there are no sample unique values for the row.
fM is the number of MSUs found for the row.
msu is the Minimum Sample Unique for the row - that is, the smallest number of
fields where the row is unique.
suda is the SUDA calculated score, adding together the individual MSU scores
(each MSU score is the factorial of the number of attributes in the dataset minus the MSU.)
dis-suda is the file-level risk score (DIS) divided by the total SUDA scores, multiplied
by SUDA for the row. In other words, the total risk distributed by the rows.
Command line
Use the command line function to supply a CSV file for the input, a path to output the resulting CSV, the minimum MSU, the columns to include, and the file-level risk (DIS).
References
Elliot, M. J., Manning, A. M., & Ford, R. W. (2002). A Computational Algorithm for Handling the Special Uniques Problem. International Journal of Uncertainty, Fuzziness and Knowledge Based System , 10 (5), 493-509.
Elliot, M. J., Manning, A., Mayes, K., Gurd, J., & Bane, M. (2005). SUDA: A Program for Detecting Special Uniques. Joint UNECE/Eurostat Work Session on Statistical Data Confidentiality. Geneva.
Metadata
Release files for suda 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| suda-0.2.2.tar.gz | 6.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| suda-0.2.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 11.7 kB
Release files / suda-0.2.2.tar.gz
| Download URL | suda-0.2.2.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2029ba311686f3180ac1724ab6bcfe71aedd71e4fdaa798b3bc2e805b7608130
|
|
BLAKE2b-256 checksum How to use checksums |
25a1ab7e3ed2375d6641aee94adf6737fb29411f7885d6a54ff496d63cde1150
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2024.
Transparency logRelease files / suda-0.2.2-py2.py3-none-any.whl
| Download URL | suda-0.2.2-py2.py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
882d8d41dcd38812537e2802369482cf35041c3e79cfc7e5db9207b797760a0f
|
|
BLAKE2b-256 checksum How to use checksums |
21d2cc2fa6d3add1fa8a4f889d70e62ad7c649f0cfb9e5a55bd3806acd7c387a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2024.
Transparency logSecurity for suda 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for suda-0.2.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2024.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.