PrERT-CNM-v4

Phase 3 Implementation Runbook

This runbook executes the Phase 3 classifier-and-risk pipeline in an isolated output folder.

Scope

Current Snapshot (Comparable Baseline vs Upgraded)

From the latest full-data comparable runs:

Visualisations

Inputs

Default source:

Optional source:

Normalized Polisis row contract:

Commands

Run Phase 3 baseline using OPP-115 default input set:

PYTHONPATH=src python scripts/run_phase3_baseline.py

Equivalent package command:

prert-phase3

Run with a custom labeled JSONL dataset:

PYTHONPATH=src python scripts/run_phase3_baseline.py \
  --labeled-input-path data/processed/phase3_labeled.jsonl \
  --output-dir artifacts/phase-3

Run with normalized Polisis source files:

PYTHONPATH=src python scripts/run_phase3_baseline.py \
  --polisis-root data/raw/Polisis \
  --polisis-input-set normalized \
  --output-dir artifacts/phase-3

Run a bounded sample for quick iteration:

PYTHONPATH=src python scripts/run_phase3_baseline.py \
  --max-rows 5000 \
  --seed 42

Run with explicit run metadata and measurement controls:

PYTHONPATH=src python scripts/run_phase3_baseline.py \
  --run-id phase3-2026-04-07-a \
  --calibration-bins 10 \
  --bootstrap-resamples 1000 \
  --output-dir artifacts/phase-3-nb

Run with the upgraded TF-IDF + weighted logistic regression model:

PYTHONPATH=src python scripts/run_phase3_baseline.py \
  --model-type logreg_tfidf \
  --max-features 20000 \
  --ngram-max 2 \
  --max-iter 1000 \
  --output-dir artifacts/phase-3-logreg

Run with the PrivacyBERT backend scaffold:

PYTHONPATH=src python scripts/run_phase3_baseline.py \
  --model-type privacybert \
  --privacybert-model-name bert-base-uncased \
  --privacybert-epochs 2 \
  --privacybert-batch-size 8 \
  --privacybert-learning-rate 5e-5 \
  --privacybert-max-length 256 \
  --output-dir artifacts/phase-3-privacybert

Run with custom Bayesian priors (enabled by default):

PYTHONPATH=src python scripts/run_phase3_baseline.py \
  --model-type logreg_tfidf \
  --bayesian-priors-path configs/phase3_bayesian_priors.json \
  --bayesian-top-k 5 \
  --output-dir artifacts/phase-3

Disable Bayesian scoring output (benchmark/diagnostic only):

PYTHONPATH=src python scripts/run_phase3_baseline.py \
  --model-type logreg_tfidf \
  --disable-bayesian-scoring \
  --output-dir artifacts/phase-3-no-bayes

Run a comparable full-data Naive Bayes baseline for side-by-side benchmarking:

PYTHONPATH=src python scripts/run_phase3_baseline.py \
  --model-type naive_bayes \
  --output-dir artifacts/phase-3-nb

Run a proposal-aligned Phase 3 acceptance freeze (PrivacyBERT + Bayesian-primary checks):

PYTHONPATH=src python scripts/run_phase3_acceptance_freeze.py \
  --model-type privacybert \
  --strict \
  --output-dir artifacts/phase-3-freeze

Run acceptance freeze with Polisis advisory reporting (non-blocking for current milestone):

PYTHONPATH=src python scripts/run_phase3_acceptance_freeze.py \
  --polisis-root data/raw/Polisis \
  --polisis-input-set normalized \
  --output-dir artifacts/phase-3-freeze

Outputs

Written to the selected --output-dir (for example artifacts/phase-3/, artifacts/phase-3-nb/, or artifacts/phase-3-logreg/):

Quality Checks

Verification

Run pipeline tests:

PYTHONPATH=src pytest -q tests/test_phase3_pipeline.py tests/test_phase3_analytics.py

Run the cross-phase regression check used in this workspace:

PYTHONPATH=src pytest -q tests/test_phase2_pipeline.py tests/test_phase3_pipeline.py

Regenerate dashboard figures (Figure 5-17):

PYTHONPATH=src python scripts/generate_phase3_dashboard_figures.py

Notes


⬅ Back Next ⮕