Skip to main content

Presidio-research

This package provides evaluation and data-science capabilities for Presidio and PII detection models in general.

It also includes a fake data generator that creates synthetic sentences based on templates and fake PII.

Who should use it?

  • Anyone interested in developing or evaluating PII detection models, an existing Presidio instance or a Presidio PII recognizer.
  • Anyone interested in generating new data based on previous datasets or sentence templates (e.g., to increase the coverage of entity values) for Named Entity Recognition models.

Getting started

Using notebooks

The easiest way to get started is by reviewing the notebooks.

  • Notebook 1: Shows how to use the PII data generator.
  • Notebook 2: Shows a simple analysis of the PII dataset.
  • Notebook 3: Provides tools to split the dataset into train/test/validation sets while avoiding leakage due to the same pattern appearing in multiple folds (only applicable for synthetically generated data).
  • Notebook 4: Shows how to use the evaluation tools to evaluate how well Presidio detects PII. Note that this is using the vanilla Presidio, and the results aren't very accurate.
  • Notebook 5: Shows how one can configure Presidio to detect PII much more accurately, and boost the f score in ~30%.
  • Notebook 6: Explains the entity mapping process, which is crucial when evaluating multiple models each returning a different set of entities.

Installation

From PyPI

pip install presidio-evaluator
python -m spacy download en_core_web_sm # for tokenization
python -m spacy download en_core_web_lg # for NER

From source

To install the package:

  1. Clone the repo
  2. Install all dependencies:
# Install uv if not already installed
pip install uv

# Install package + dev dependencies
uv sync --extra dev

# Download the spaCy pipeline used for tokenization
uv run python -m spacy download en_core_web_sm

# To use the default Presidio configuration, a spaCy model is required:
uv run python -m spacy download en_core_web_lg

# Verify installation
uv run pytest

Note that some dependencies (such as Flair and Stanza) are no longer supported. Use Presidio Analyzer directly to add custom NER models.

What's in this package?

  1. Fake data generator for PII recognizers and NER models
  2. Data representation layer for data generation, modeling and analysis
  3. Model/Recognizer evaluation for Presidio Analyzer and custom Presidio recognizers
  4. Helper functions for results analysis

1. Data generation

See Data Generator README for more details.

The data generation process takes a file with templates, e.g. My name is {{name}}. Then, it creates new synthetic sentences by sampling templates and PII values. Furthermore, it tokenizes the data, creates tags (either IO/BIO/BILUO) and spans for the newly created samples.

Once data is generated, it could be split into train/test/validation sets while ensuring that each template only exists in one set. See this notebook for more details.

2. Data representation

In order to standardize the process, we use specific data objects that hold all the information needed for generating, analyzing, modeling and evaluating data and models. Specifically, see data_objects.py.

The standardized structure, List[InputSample], can be translated into different formats:

  • CoNLL

    • To CoNLL:

      from presidio_evaluator import InputSample
      dataset = InputSample.read_dataset_json("data/synth_dataset_v2.json")
      conll = InputSample.create_conll_dataset(dataset)
      conll.to_csv("dataset.csv", sep="\t")
      
    • From CoNLL

      from pathlib import Path
      from presidio_evaluator.dataset_formatters import CONLL2003Formatter
      # Read from a folder containing ConLL2003 files
      conll_formatter = CONLL2003Formatter(files_path=Path("data/conll2003").resolve())
      train_samples = conll_formatter.to_input_samples(fold="train")
      
  • spaCy v3

    from presidio_evaluator import InputSample
    dataset = InputSample.read_dataset_json("data/synth_dataset_v2.json")
    InputSample.create_spacy_dataset(dataset, output_path="dataset.spacy")
    
  • json

    from presidio_evaluator import InputSample
    dataset = InputSample.read_dataset_json("data/synth_dataset_v2.json")
    InputSample.to_json(dataset, output_file="dataset_json")
    

3. PII models evaluation

The presidio-evaluator framework allows you to evaluate Presidio as a system, a NER model, or a specific PII recognizer for precision, recall, and error analysis. See Notebook 5 for an example.

For more information

Contributing

This project welcomes contributions and suggestions. Open an issue to discuss larger changes before submitting a pull request.

This project has adopted the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to presidio@dataprivacystack.org.

Copyright notice:

Fake Name Generator identities by the Fake Name Generator are licensed under a Creative Commons Attribution-Share Alike 3.0 United States License. Fake Name Generator and the Fake Name Generator logo are trademarks of Corban Works, LLC.

Release files for presidio-evaluator 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for presidio-evaluator 0.3.2
File Size Uploaded
presidio_evaluator-0.3.2.tar.gz 1.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for presidio-evaluator 0.3.2
File Interpreter ABI Platform
presidio_evaluator-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 2.6 MB

Release files / presidio_evaluator-0.3.2.tar.gz

Download URL presidio_evaluator-0.3.2.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
2ec1be3710a2843553a5fb185916d85b0fa174fb9e1927e03ea83152fdc95eb1
BLAKE2b-256 checksum
How to use checksums
ed9378b98353915eac13a28a720f120f6d3bcd952c51dbf563be27d74a1dbc76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 4, 2026.

Transparency log

Release files / presidio_evaluator-0.3.2-py3-none-any.whl

Download URL presidio_evaluator-0.3.2-py3-none-any.whl
Size 694.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57614fe604e52b78e6de25b767c59265886b93bbcdc6c7e43ab2657d3f6302be
BLAKE2b-256 checksum
How to use checksums
472e2c1b3160e106329679ae7095dcdd1336b2019bf1fe2e8731c2a489dc954e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 4, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3

2 release files

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page