You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,40 @@
1
1
# CHANGELOG
2
2
3
+
## Unreleased
4
+
5
+
> **Migration guide:** See [docs/migration-guide.md](docs/migration-guide.md) for step-by-step upgrade instructions.
6
+
7
+
### Breaking Changes
8
+
9
+
-**`evaluate_all()` removed** — raises `DeprecationError` at runtime. Replace with the three-step pipeline: `predict_dataset()` → `CanonicalMapper.get_mapped_results_dataframe()` → `calculate_score_on_df()`.
10
+
-**`entity_mapping` parameter removed** from `SpanEvaluator`, `TokenEvaluator`, and `BaseEvaluator` — entity mapping is now the responsibility of `CanonicalMapper`.
11
+
-**`compare_by_io` parameter removed** from evaluator constructors — BIO/BILUO prefix stripping is now performed by `CanonicalMapper`.
12
+
-**`BaseEvaluator.from_dataset()` removed** — use `model.predict_dataset(dataset)` directly.
13
+
-**Non-Presidio model wrappers removed**: `FlairModel`, `SpacyModel`, `StanzaModel`, `AzureAITextAnalyticsWrapper`. Add models directly through Presidio to evaluate them.
14
+
-**Minimum Python version raised to 3.11** (was 3.10) — required by `numpy >= 2.4.0`.
15
+
-**Package manager changed from Poetry to uv** — install with `uv sync`, run with `uv run`.
16
+
17
+
### New Features
18
+
19
+
-**`BaseModel.predict_dataset(dataset)`** — runs the model on a list of `InputSample` objects and returns a 5-column DataFrame (`sentence_id`, `token`, `annotation`, `prediction`, `start_indices`).
20
+
-**`CanonicalMapper`** — replaces `EntityMappingHelper` with an improved four-tier auto-resolution strategy (`EXACT`, `COUNTRY`, `FUZZY`, `PENDING`). Key methods:
21
+
-`CanonicalMapper.from_dataset(dataset)` — builds a mapper from dataset labels.
22
+
-`mapper.get_mapped_results_dataframe(results_df)` — applies entity mapping to a predictions DataFrame.
23
+
-`mapper.get_mapping(mode='html' | 'text')` — returns the final `{raw_label: canonical | None}` dict.
-`mapper.render_html()` — display the resolution audit table in Jupyter.
26
+
-**`TokenEvaluator.calculate_score_on_df(results_df)`** — score token-level predictions from a DataFrame.
27
+
-**`SpanEvaluator.calculate_score_on_df(per_type, results_df)`** — score span-level predictions from a DataFrame.
28
+
-**Ruff** — added as the project linter and formatter (`ruff.toml` at project root).
29
+
-**Pre-commit hooks** — `ruff format`, `ruff check`, and `pytest` run automatically before every commit (`.pre-commit-config.yaml`).
30
+
-**Test reorganisation** — tests are now grouped by topic (`tests/data_generator/`, `tests/entity_mapping/`, `tests/evaluation/`, `tests/models/`, `tests/integration/`). Integration tests are tagged with `pytest.mark.integration`.
31
+
32
+
### Deprecations
33
+
34
+
-**`evaluator.get_results_dataframe()`** — soft `DeprecationWarning` emitted at runtime. Replace with `model.predict_dataset(dataset)`.
Copy file name to clipboardExpand all lines: README.md
+13-24Lines changed: 13 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Presidio-research
2
2
3
-
This package provides evaluation and data-science capabilities for
3
+
This package provides evaluation and data-science capabilities for
4
4
[Presidio](https://github.com/microsoft/presidio) and PII detection models in general.
5
5
6
6
It also includes a fake data generator that creates synthetic sentences based on templates and fake PII.
@@ -20,16 +20,13 @@ The easiest way to get started is by reviewing the notebooks.
20
20
-[Notebook 3](notebooks/3_Split_by_pattern_number.ipynb): 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).
21
21
-[Notebook 4](notebooks/4_Evaluate_Presidio_Analyzer.ipynb): 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.
22
22
-[Notebook 5](notebooks/5_Evaluate_Custom_Presidio_Analyzer.ipynb): Shows how one can configure Presidio to detect PII much more accurately, and boost the f score in ~30%.
23
+
-[Notebook 6](notebooks/6_Interactive_Entity_Mapping.ipynb): Explains the entity mapping process, which is crucial when evaluating multiple models each returning a different set of entities.
23
24
24
25
### Installation
25
26
26
-
>Note: Presidio evaluator requires Python version 3.9 or higher.
27
-
28
27
#### From PyPI
29
28
30
29
```sh
31
-
conda create --name presidio python=3.12
32
-
conda activate presidio
33
30
pip install presidio-evaluator
34
31
python -m spacy download en_core_web_sm # for tokenization
35
32
python -m spacy download en_core_web_lg # for NER
@@ -43,31 +40,29 @@ To install the package:
43
40
2. Install all dependencies:
44
41
45
42
```sh
46
-
# Install package+dependencies
47
-
pip install poetry
48
-
poetry install --with=dev
43
+
# Install uv if not already installed
44
+
pip install uv
49
45
50
-
#Download tge spaCy pipeline used for tokenization
51
-
poetry run python -m spacy download en_core_web_sm
46
+
#Install package + dev dependencies
47
+
uv sync --extra dev
52
48
53
-
#To install with all additional NER dependencies (e.g. Flair, Stanza), run:
54
-
# poetry install --with='ner,dev'
49
+
#Download the spaCy pipeline used for tokenization
50
+
uv run python -m spacy download en_core_web_sm
55
51
56
52
# To use the default Presidio configuration, a spaCy model is required:
57
-
poetry run python -m spacy download en_core_web_lg
53
+
uv run python -m spacy download en_core_web_lg
58
54
59
55
# Verify installation
60
-
pytest
56
+
uv run pytest
61
57
```
62
58
63
-
Note that some dependencies (such as Flair and Stanza) are not automatically installed to reduce installation complexity.
59
+
Note that some dependencies (such as Flair and Stanza) are no longer supported. Use Presidio Analyzer directly to add custom NER models.
64
60
65
61
## What's in this package?
66
62
67
63
1.**Fake data generator** for PII recognizers and NER models
68
64
2.**Data representation layer** for data generation, modeling and analysis
69
-
3. Multiple **Model/Recognizer evaluation** files (e.g. for Presidio, Spacy, Flair, Azure AI Language)
70
-
4.**Training and modeling code** for multiple models
65
+
3.**Model/Recognizer evaluation** for Presidio Analyzer and custom Presidio recognizers
71
66
5. Helper functions for **results analysis**
72
67
73
68
## 1. Data generation
@@ -120,13 +115,6 @@ The standardized structure, `List[InputSample]`, can be translated into differen
@@ -140,6 +128,7 @@ The presidio-evaluator framework allows you to evaluate Presidio as a system, a
140
128
141
129
## For more information
142
130
131
+
-[Blog post on PII evaluation](https://omri-mendels.medium.com/evaluating-pii-detection-models-fa0c745d7a4c)
143
132
-[Blog post on NLP approaches to data anonymization](https://towardsdatascience.com/nlp-approaches-to-data-anonymization-1fb5bde6b929)
144
133
-[How to evaluate PII Detection output with Presidio Evaluator](https://tranguyen221.medium.com/how-to-evaluate-pii-detection-output-with-presidio-evaluator-3f2684ba3091)
145
134
-[Conference talk about leveraging Presidio and utilizing NLP approaches for data anonymization](https://youtu.be/Tl773LANRwY)
0 commit comments