From 883f14ab79b36e2aee9cb016827eabaf3b06ee12 Mon Sep 17 00:00:00 2001 From: Domi31tls Date: Mon, 2 Mar 2026 15:16:30 +0100 Subject: [PATCH] =?UTF-8?q?test:=20Validation=20correction=20fuites=20-=20?= =?UTF-8?q?Rappel=20100%,=20Pr=C3=A9cision=2088.27%=20maintenue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Évaluation qualité après correction propagation globale sélective: - Rappel: 100.00% ✅ (objectif ≥99.5%) - Précision: 88.27% ⚠️ (objectif ≥97%, écart -8.73pts) - F1-Score: 93.77% ⚠️ (objectif ≥98%, écart -4.23pts) - 0 faux négatif (FN=0) - Aucune fuite - 154 faux positifs restants (EPISODE: 106, VILLE: 20, autres: 28) Prochaine optimisation: Filtrage EPISODE (69% des FP restants) --- anonymizer_core_refactored_onnx.py | 11 +- .../quality_evaluation_after_leak_fix.log | 187 ++++++++++++++++++ 2 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 tests/ground_truth/quality_evaluation_after_leak_fix.log diff --git a/anonymizer_core_refactored_onnx.py b/anonymizer_core_refactored_onnx.py index 982f812..80cf722 100644 --- a/anonymizer_core_refactored_onnx.py +++ b/anonymizer_core_refactored_onnx.py @@ -1304,8 +1304,12 @@ def anonymise_document_regex(pages_text: List[str], tables_lines: List[List[str] table_blocks.append("\n".join(mbuf)) tables_block = "\n\n".join(table_blocks) text_out = "\f".join(out_pages) # séparateur de pages - if tables_block.strip(): - text_out += "\n\n[TABLES]\n" + tables_block + "\n[/TABLES]" + # NOTE: on n'ajoute PAS le bloc [TABLES] au text_out. + # pdfplumber extrait souvent le contenu principal comme "table", créant un doublon + # intégral du texte. Ce doublon échappait au NER et au rescan (protégé par les + # marqueurs [TABLES]), et le NER EDS-pseudo corrompait les marqueurs en changeant + # la longueur du texte → fuite PII massive (dates de naissance, adresses, noms). + # Les PII détectés dans les tables sont toujours dans l'audit (Phase 1 regex). # Phase 2 : application globale des noms extraits (rattrapage) if extracted_names: @@ -2187,6 +2191,9 @@ def process_pdf( except Exception as e: log.warning("Erreur lors du filtrage hospitalier : %s", e) + # Sécurité : supprimer tout bloc [TABLES] résiduel (ne devrait plus arriver) + final_text = re.sub(r"\n*\[TABLES\].*?\[/TABLES\]\n*", "\n", final_text, flags=re.DOTALL) + # Sauvegardes base = pdf_path.stem txt_path = out_dir / f"{base}.pseudonymise.txt" diff --git a/tests/ground_truth/quality_evaluation_after_leak_fix.log b/tests/ground_truth/quality_evaluation_after_leak_fix.log new file mode 100644 index 0000000..dc18e73 --- /dev/null +++ b/tests/ground_truth/quality_evaluation_after_leak_fix.log @@ -0,0 +1,187 @@ +================================================================================ +ÉVALUATION DE LA QUALITÉ D'ANONYMISATION +================================================================================ + +📁 Annotations: tests/ground_truth/annotations +📁 Détections: tests/ground_truth/pdfs/baseline_anonymized +📁 Résultats: tests/ground_truth/quality_evaluation + +📄 Documents à évaluer: 25 + +[1/25] 001_simple_unknown_BACTERIO_23018396 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 10 FP: 0 FN: 0 + +[2/25] 002_simple_unknown_bacterio_476_23159413 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 11 FP: 0 FN: 0 + +[3/25] 003_simple_compte_rendu_CRO_23155084 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 4 FP: 0 FN: 0 + +[4/25] 004_simple_anapath_anapath_53_23224186.redacted_raster + Précision: 0.00% Rappel: 0.00% F1: 0.00% + TP: 0 FP: 0 FN: 0 + +[5/25] 005_simple_compte_rendu_CRH_23155836 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 62 FP: 0 FN: 0 + +[6/25] 008_simple_trackare_trackare-14004105-23202435_14004105_23202435 + Précision: 57.69% Rappel: 100.00% F1: 73.17% + TP: 15 FP: 11 FN: 0 + +[7/25] 009_simple_compte_rendu_CRO_23051225 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 8 FP: 0 FN: 0 + +[8/25] 010_simple_anapath_ANAPATH_23217289 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 13 FP: 0 FN: 0 + +[9/25] 011_moyen_compte_rendu_CRH_23080179 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 12 FP: 0 FN: 0 + +[10/25] 012_moyen_compte_rendu_CRH_692_23200418 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 30 FP: 0 FN: 0 + +[11/25] 013_moyen_compte_rendu_363_23085243_CRO + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 32 FP: 0 FN: 0 + +[12/25] 014_moyen_compte_rendu_CRO_23167029.redacted_raster + Précision: 0.00% Rappel: 0.00% F1: 0.00% + TP: 0 FP: 0 FN: 0 + +[13/25] 015_moyen_unknown_CONSULTATION_ANESTHESISTE_23139653 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 7 FP: 0 FN: 0 + +[14/25] 016_moyen_compte_rendu_CRH_23149905 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 114 FP: 0 FN: 0 + +[15/25] 017_moyen_compte_rendu_CRO_23222062.redacted_raster + Précision: 0.00% Rappel: 0.00% F1: 0.00% + TP: 0 FP: 0 FN: 0 + +[16/25] 018_moyen_compte_rendu_CRH_23042753 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 123 FP: 0 FN: 0 + +[17/25] 019_moyen_compte_rendu_CRO_332_23049003 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 55 FP: 0 FN: 0 + +[18/25] 020_moyen_compte_rendu_CRO_23084754.redacted_raster + Précision: 0.00% Rappel: 0.00% F1: 0.00% + TP: 0 FP: 0 FN: 0 + +[19/25] 021_moyen_compte_rendu_CRO_23201117.redacted_raster + Précision: 0.00% Rappel: 0.00% F1: 0.00% + TP: 0 FP: 0 FN: 0 + +[20/25] 022_moyen_compte_rendu_cro2_516_23187028 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 4 FP: 0 FN: 0 + +[21/25] 023_complexe_compte_rendu_CRH_23102610 + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 379 FP: 0 FN: 0 + +[22/25] 024_complexe_trackare_trackare-17001141-23066188_17001141_23066188 + Précision: 64.63% Rappel: 100.00% F1: 78.52% + TP: 53 FP: 29 FN: 0 + +[23/25] 025_complexe_trackare_trackare-02016820-23095226_02016820_23095226 + Précision: 68.57% Rappel: 100.00% F1: 81.36% + TP: 96 FP: 44 FN: 0 + +[24/25] 026_complexe_trackare_trackare-15000536-23074384_15000536_23074384 + Précision: 66.95% Rappel: 100.00% F1: 80.20% + TP: 79 FP: 39 FN: 0 + +[25/25] 027_complexe_trackare_trackare-10027557-23183041_10027557_23183041 + Précision: 62.65% Rappel: 100.00% F1: 77.04% + TP: 52 FP: 31 FN: 0 + +================================================================================ +RÉSULTATS GLOBAUX +================================================================================ + +📊 Métriques: + - Précision: 88.27% + - Rappel: 100.00% + - F1-Score: 93.77% + +📊 Détails: + - Vrais positifs (TP): 1159 + - Faux positifs (FP): 154 + - Faux négatifs (FN): 0 + +📊 Métriques par type de PII: + - ADRESSE: + Précision: 87.80% Rappel: 100.00% F1: 93.51% + TP: 72 FP: 10 FN: 0 + - AGE: + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 5 FP: 0 FN: 0 + - CODE_POSTAL: + Précision: 83.33% Rappel: 100.00% F1: 90.91% + TP: 50 FP: 10 FN: 0 + - DATE_NAISSANCE: + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 114 FP: 0 FN: 0 + - DOSSIER: + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 3 FP: 0 FN: 0 + - EMAIL: + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 62 FP: 0 FN: 0 + - EPISODE: + Précision: 14.52% Rappel: 100.00% F1: 25.35% + TP: 18 FP: 106 FN: 0 + - ETABLISSEMENT: + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 83 FP: 0 FN: 0 + - IPP: + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 25 FP: 0 FN: 0 + - NIR: + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 2 FP: 0 FN: 0 + - NOM: + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 506 FP: 0 FN: 0 + - RPPS: + Précision: 100.00% Rappel: 100.00% F1: 100.00% + TP: 21 FP: 0 FN: 0 + - TEL: + Précision: 96.02% Rappel: 100.00% F1: 97.97% + TP: 193 FP: 8 FN: 0 + - VILLE: + Précision: 20.00% Rappel: 100.00% F1: 33.33% + TP: 5 FP: 20 FN: 0 + +================================================================================ +VALIDATION DES OBJECTIFS +================================================================================ + +🎯 Objectifs: + - Rappel: ≥ 99.5% + - Précision: ≥ 97.0% + - F1-Score: ≥ 98.00% + +📊 Résultats: + ✅ Rappel atteint: 100.00% ≥ 99.5% + ⚠️ Précision non atteinte: 88.27% < 97.0% + Écart: 8.73 points + ⚠️ F1-Score non atteint: 93.77% < 98.00% + Écart: 4.23 points + +📊 Résultats sauvegardés: tests/ground_truth/quality_evaluation/baseline_quality_evaluation.json + +================================================================================