Search…
⌃K
Links

AnonymizedFaker

Compatibility: pii data
The AnonymizedFaker anonymizes private or sensitive data. When transforming the data, it simply removes the column. When reversing the transform, it anonymizes the column by creating completely new, fake data at random using the Python Faker library.
from rdt.transformers.pii import AnonymizedFaker
af = AnonymizedFaker()
You can specify the exact faker method to use for more realistic data.

Parameters

provider_name: The name of the provider to use from the Faker library.
(default) None
Use the BaseProvider from Faker, which capable of creating random text.
<string>
Use the provider for a specific context, for example "address" or "bank".
function_name: The name of the function to use within the Faker provider.
(default) 'lexify'
Use the lexify method to create random 4-character text.
<string>
Use the function from the specified provider to generate fake data. For example, "street_address" from the address provider or "swift" from the bank provider.
Together, the provider_name and function_name parameters specify exactly how to create fake data. Some common values are:
To browse for more options, visit the Faker library's docs.
function_kwargs: Optional parameters to pass into the function that you're specifying to create Fake data.
(default) None
Do not specify any additional parameters
<dictionary>
Additional parameters to add. These are unique to the function name and should be represented as a dictionary. For example for the banking "swift" function, you can specify: {"length": 11, "primary": True}.
locales: An optional list of locales to use when generating the Fake data.
(default) None
Use the default locale, which is usually set to the country you are in.
<list>
Create data from the list of locales. These are specified as strings representing the language and country from Faker. For example ["en_US", "fr_CA"].
Setting a locale might leak information about the original data. Anyone with access to the anonymized data will be able to tell which countries and locales are included in the original data .
enforce_uniqueness: Whether to guarantee that the created fake data will be unique
(default) False
The generated data may contain repeating values
True
The generated data will not contain any repeating values

Examples

from transformers.pii import AnonymizedFaker
# create more realistic-looking data by specifying a provider and function
af = AnonymizedFaker(
provider_name="person",
function_name="name",
enforce_uniqueness=True
)

FAQs

Use the AnonymizedFaker whenever you have sensitive data that should not be part of your data science project. By default, the transformer reverses the transform into fake, 4-character strings such as "UaNJ" in place of the original, sensitive data.
Use this transformer as-is if the values in your sensitive data do not matter. Alternatively, supply a provider and function name to create fake data that looks more realistic.
The AnonymizedFaker generates fake data randomly without looking at the real values. So there is a small chance that a real value may show up in the real data by complete coincidence. For example, if your real data had a phone number "(617)123-4567", there's a small probability that the exact same phone number will be created by random chance.
This behavior actually protects your sensitive data! Otherwise, anyone with access to the fake data would be able to deduce the real values by noting down what's missing.
Pseudo-anonymization indicates that the anonymization scheme can be reversed while anonymization indicates that it's permanent.
This transformer anonymizes data in an irreversible way by creating fake data in a completely random fashion. It will not be possible to guess the real values based on the fake values. This behavior allows you to protect the sensitive values in your data.
If you want to anonymize your data in a reversible way, use the PseudoAnonymizedFaker instead.