Skip to main content

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

Build Status License Status Supported versions

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.

From the command line you can also use the -f switch to print a table of the frequencies of categories in the original and changed versions of the dataset.

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

pram-0.1.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

pram-0.1.2-py2.py3-none-any.whl (5.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pram-0.1.2.tar.gz.

File metadata

  • Download URL: pram-0.1.2.tar.gz
  • Upload date:
  • Size: 5.4 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

Hashes for pram-0.1.2.tar.gz
Algorithm Hash digest
SHA256 65474b19f1d95ef9f560c6721058b2bb406ee0fa4890b9fba7442ef7e619771d
MD5 2e9e5e9143353ea6a067685fa5fd6ee3
BLAKE2b-256 23bb0edf8eb2c3f0b2b77f78e0b6838f693de03c5d4a66600067f80df5aec1b4

See more details on using hashes here.

File details

Details for the file pram-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: pram-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.3 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

Hashes for pram-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3fc786315e8b927b68e71fc961f23ed6cfbfecfbb9ddeeb2490b98c038859de3
MD5 571660bab30c7d59dba796178091315f
BLAKE2b-256 0103147d5cf90648f75faeec63f4c9c635d61aa9bbc8c43111713fe024f10771

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page