Python library for implementing post-randomisation method (PRAM) for disclosure control in synthetic data
Project description
pram
Python implementation of post-randomisation method for disclosure control
Usage
Call the pram() method with a Pandas dataframe to apply post-randomisation perturbation to the dataset using a generated transition matrix.
You can specify the minimum diagonal value (i.e. the minimum probability that a data point remains unchanged) and an alpha value to modify the likelihood of perturbation (from zero to one).
The behaviour is largely the same as that in the "sdcMicro" R package.
Command-line usage
You can also call Pram from the command line, supplying a CSV file input and path to output the perturbed dataset as CSV.
Example
persons = [
{'gender': 'female', 'region': 'rural', 'education': 'higher', 'age': 27},
{'gender': 'female', 'region': 'rural', 'education': 'lower', 'age': 35},
{'gender': 'male', 'region': 'rural', 'education': 'lower', 'age': 26},
{'gender': 'male', 'region': 'rural', 'education': 'lower', 'age': 22},
{'gender': 'female', 'region': 'urban', 'education': 'higher', 'age': 41},
{'gender': 'female', 'region': 'urban', 'education': 'lower', 'age': 54},
{'gender': 'female', 'region': 'rural', 'education': 'higher', 'age': 38},
{'gender': 'female', 'region': 'rural', 'education': 'lower', 'age': 44},
{'gender': 'male', 'region': 'rural', 'education': 'lower', 'age': 18},
{'gender': 'male', 'region': 'rural', 'education': 'lower', 'age': 52},
{'gender': 'female', 'region': 'urban', 'education': 'higher', 'age': 44},
{'gender': 'female', 'region': 'urban', 'education': 'lower', 'age': 35},
{'gender': 'female', 'region': 'rural', 'education': 'higher', 'age': 33},
{'gender': 'female', 'region': 'rural', 'education': 'lower', 'age': 31},
{'gender': 'male', 'region': 'rural', 'education': 'lower', 'age': 40},
{'gender': 'male', 'region': 'rural', 'education': 'lower', 'age': 23},
{'gender': 'female', 'region': 'urban', 'education': 'higher', 'age': 68},
{'gender': 'female', 'region': 'urban', 'education': 'lower', 'age': 19},
{'gender': 'female', 'region': 'rural', 'education': 'higher', 'age': 27},
{'gender': 'female', 'region': 'rural', 'education': 'lower', 'age': 24},
{'gender': 'male', 'region': 'rural', 'education': 'lower', 'age': 48},
{'gender': 'male', 'region': 'rural', 'education': 'lower', 'age': 38},
{'gender': 'female', 'region': 'urban', 'education': 'higher', 'age': 30},
{'gender': 'female', 'region': 'urban', 'education': 'lower', 'age': 27}
]
df = pd.DataFrame(persons)
print(Pram.pram(df))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pram-0.1.1.tar.gz
.
File metadata
- Download URL: pram-0.1.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 180b066b48a4333af0ceeb06a6df8e3b8bcc77b4a27815d33804598ffd488da8 |
|
MD5 | 5d5be7abde6c89c41bf7cc1666615f67 |
|
BLAKE2b-256 | 17213f5b29830bfce3dae88d7aec0b4609ca830d48be795df8d9703d2cc5ffba |
File details
Details for the file pram-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: pram-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3867c15dd0a9820563aa56e0f565cecaffed40b0d30803baea15ed3b055718c6 |
|
MD5 | 6446f17c206941b2fdcd5e2cffab1b58 |
|
BLAKE2b-256 | 407f563f68cd6772d363dae6a804b9f88c57b4023c83f3332983f9324e2e4105 |