ClassifierDriftMonitor

Classifier Drift Monitor

Liquid Biopsy жидкостная биопсия cfDNA ctDNA CTC exosomes NGS qPCR
Open selection

Utility description: Classifier Drift Monitor

Classifier Drift Monitor — ML Classifier Drift Monitoring

ℹ️  Utility performs continuous monitoring of ML model stability in production according to FDA SaMD, EU AI Act and GMLP requirements:
     • PSI (Population Stability Index): Quantitative assessment of input feature and output prediction distribution changes relative to baseline.
     • KLD (Kullback-Leibler Divergence): Measurement of information distance between current and reference distributions.
     • Mean Shift: Detection of systematic shift in model predictions.
     • Graded Alerts: Separation into STABLE / WARNING / DRIFT_DETECTED for proportional response.

⚠️  IMPORTANT: 
     • Model drift often occurs silently and accumulates gradually.
     • Absence of monitoring may lead to mass diagnostic errors before problem detection.

Usage:
  ClassifierDriftMonitor.exe                            → demo mode (console output)
  ClassifierDriftMonitor.exe input.csv output.json      → evaluate your data

Input format:
ModelName,ModelVersion,MonitoringWindow,PSI_Feature_Avg,PSI_Prediction,Max_PSI_Threshold,Warning_PSI_Threshold,KLD_Score,Max_KLD_Threshold,Prediction_Mean_Shift,Max_Mean_Shift,SampleSize_Current,Min_SampleSize,Baseline_Accuracy,Current_Proxy_Accuracy

Example:
  OncoClass,v3.2,W22,0.03,0.05,0.2,0.1,0.02,0.1,0.01,0.05,450,100,0.94,0.93

📍 Scope of Application (Usage Where):
     • Clinical ML Systems: Continuous post-market model surveillance.
     • Regulatory Compliance: Documentation of SaMD stability for FDA/EMA.
     • MLOps: Automatic trigger for retraining pipeline.
     • AI Audit: Confirmation of EU AI Act compliance for high-risk AI systems.

— WHY IS THIS NEEDED?
ML models are validated on historical data, but real patient population changes.
Changes in equipment, data collection protocols, or demographics cause drift.
Without systematic monitoring, model degradation is detected only after patient harm.
Automated monitoring ensures proactive AI lifecycle management.

⚠️  CRITICAL:
• PSI Thresholds: 0.1 = warning, 0.2 = action (industry standard).
• Sample Size: Drift metrics are unreliable with small samples (<100).
• Feature vs Prediction Drift: Feature drift may precede prediction drift.
• Ground Truth: Use proxy metrics for indirect assessment when labels unavailable.

Key features:
• Multi-metric drift assessment (PSI + KLD + Mean Shift)
• Three-tier alert system
• Support for monitoring without ground truth
• Report generation for regulatory authorities
• Compliance with GMLP Principle 6 (Continuous Monitoring)

Critical parameters:
• PSI Features: < 0.1 (stable), 0.1-0.2 (warning), > 0.2 (drift)
• PSI Predictions: < 0.2
• KLD Score: < Threshold
• Mean Shift: Within tolerance
• Sample Size: ≥ Minimum

💡 Usage tips:
1. Baseline: Use validation set as reference, not training set.
2. Monitoring Window: Balance window size (not too small for noise, not too large for delay).
3. Stratified Analysis: Analyze drift separately by subgroups (age, sex, sample type).
4. Automation: Integrate with CI/CD for automatic retraining trigger.
5. Documentation: Maintain log of all alerts and actions taken.

⚠️ Note: This utility is a post-market ML model surveillance tool. It does not replace periodic full revalidation but ensures timely detection of revalidation necessity.

input.csv

ModelName,ModelVersion,MonitoringWindow,PSI_Feature_Avg,PSI_Prediction,Max_PSI_Threshold,Warning_PSI_Threshold,KLD_Score,Max_KLD_Threshold,Prediction_Mean_Shift,Max_Mean_Shift,SampleSize_Current,Min_SampleSize,Baseline_Accuracy,Current_Proxy_Accuracy
OncoClassify_v3,v3.2.1,2026-W22,0.03,0.05,0.2,0.1,0.02,0.1,0.01,0.05,450,100,0.94,0.93
MCED_TissueOrigin_v2,v2.1.0,2026-W23,0.25,0.35,0.2,0.1,0.18,0.1,-0.12,0.05,380,100,0.89,0.76
VariantPathogenicity_v1,v1.4.2,2026-W23,0.08,0.06,0.2,0.1,0.04,0.1,0.02,0.05,520,100,0.91,0.90

URS & FS — User Requirements and Functional Specification

This document describes the controlled interface and behaviour of ClassifierDriftMonitor for Classifier Drift Monitor.

Domain limits and critical parameters

Key fragments from the source description are shown below. Before production use, limits must be verified against the approved specification, registration dossier and local SOPs.
  • ⚠️ CRITICAL:
  • • Sample Size: Drift metrics are unreliable with small samples (<100).
  • Critical parameters:
  • • PSI Features: < 0.1 (stable), 0.1-0.2 (warning), > 0.2 (drift)
  • • PSI Predictions: < 0.2
  • • KLD Score: < Threshold
  • • Sample Size: ≥ Minimum

URS — User Requirements Specification

IDRequirementCriticalityAcceptance criterion
URS-001The utility shall accept an input.csv file for Classifier Drift Monitor with headers defined in the data contract.HighThe file is processed without manual header editing.
URS-002The utility shall perform deterministic QC evaluation without machine learning and without probabilistic conformance decisions.HighIdentical input data, rule version and configuration produce reproducible results.
URS-003The utility shall validate mandatory fields, data types, ranges, units and domain plausibility.HighSchema, conversion and range errors are explicitly reported.
URS-004The utility shall apply domain limits and rules from the description, approved specification, registration dossier and local SOPs.HighEach check has PASS/WARNING/FAIL and a clear message.
URS-005The utility shall generate output.json with machine-readable results, source values, warnings, failures and critical findings.HighJSON is suitable for LIMS/ELN/MES integration and QA/QC review.
URS-006The utility shall preserve traceability between batch/sample, input file, applied rules and final status.HighOutput contains identifiers, checked parameters and audit metadata.
URS-007The documentation shall support IQ/OQ/PQ, CSV/CSA and review by internal QA or inspectors.MediumURS, FS, input/output contract and test scenarios are supplied with the utility.
URS-008The utility shall be used as a QC decision-support tool and not as a substitute for approved specifications and QA/QP release decision.MediumDocumentation states change control and limit-verification expectations.

input.csv contract

#FieldTypeSamplePurpose
1ModelNamestring / controlled vocabularyOncoClassify_v3Controlled input parameter for deterministic QC rules.
2ModelVersionstring / controlled vocabularyv3.2.1Controlled input parameter for deterministic QC rules.
3MonitoringWindowstring / controlled vocabulary2026-W22Controlled input parameter for deterministic QC rules.
4PSI_Feature_Avgdecimal0.03Controlled input parameter for deterministic QC rules.
5PSI_Predictioninteger / decimal0.05Controlled input parameter for deterministic QC rules.
6Max_PSI_Thresholddecimal0.2Controlled input parameter for deterministic QC rules.
7Warning_PSI_Thresholddecimal0.1Controlled input parameter for deterministic QC rules.
8KLD_Scoredecimal0.02Controlled input parameter for deterministic QC rules.
9Max_KLD_Thresholddecimal0.1Controlled input parameter for deterministic QC rules.
10Prediction_Mean_Shiftdecimal0.01Controlled input parameter for deterministic QC rules.
11Max_Mean_Shiftdecimal0.05Controlled input parameter for deterministic QC rules.
12SampleSize_Currentstring / controlled vocabulary450Sample or laboratory specimen identifier.
13Min_SampleSizestring / controlled vocabulary100Sample or laboratory specimen identifier.
14Baseline_Accuracydecimal0.94Controlled input parameter for deterministic QC rules.
15Current_Proxy_Accuracydecimal0.93Controlled input parameter for deterministic QC rules.
ModelName,ModelVersion,MonitoringWindow,PSI_Feature_Avg,PSI_Prediction,Max_PSI_Threshold,Warning_PSI_Threshold,KLD_Score,Max_KLD_Threshold,Prediction_Mean_Shift,Max_Mean_Shift,SampleSize_Current,Min_SampleSize,Baseline_Accuracy,Current_Proxy_Accuracy
OncoClassify_v3,v3.2.1,2026-W22,0.03,0.05,0.2,0.1,0.02,0.1,0.01,0.05,450,100,0.94,0.93
MCED_TissueOrigin_v2,v2.1.0,2026-W23,0.25,0.35,0.2,0.1,0.18,0.1,-0.12,0.05,380,100,0.89,0.76
VariantPathogenicity_v1,v1.4.2,2026-W23,0.08,0.06,0.2,0.1,0.04,0.1,0.02,0.05,520,100,0.91,0.90

Input validation rules

IDFieldRuleCriticality
VR-001ModelNameThe field shall match an approved dictionary or accepted string representation.High
VR-002ModelVersionThe field shall match an approved dictionary or accepted string representation.High
VR-003MonitoringWindowThe field shall match an approved dictionary or accepted string representation.High
VR-004PSI_Feature_AvgThe field shall match an approved dictionary or accepted string representation.Medium
VR-005PSI_PredictionThe field shall match an approved dictionary or accepted string representation.Medium
VR-006Max_PSI_ThresholdThe field shall match an approved dictionary or accepted string representation.Medium
VR-007Warning_PSI_ThresholdThe field shall match an approved dictionary or accepted string representation.Medium
VR-008KLD_ScoreThe field shall match an approved dictionary or accepted string representation.Medium
VR-009Max_KLD_ThresholdThe field shall match an approved dictionary or accepted string representation.Medium
VR-010Prediction_Mean_ShiftThe field shall match an approved dictionary or accepted string representation.Medium
VR-011Max_Mean_ShiftThe field shall match an approved dictionary or accepted string representation.Medium
VR-012SampleSize_CurrentThe field shall match an approved dictionary or accepted string representation.Medium
VR-013Min_SampleSizeThe field shall match an approved dictionary or accepted string representation.Medium
VR-014Baseline_AccuracyThe field shall match an approved dictionary or accepted string representation.Medium
VR-015Current_Proxy_AccuracyThe field shall match an approved dictionary or accepted string representation.Medium

FS — Functional Specification

IDFunctionImplementation
FS-001CLI executionSupport execution modes: demo mode without arguments and production mode input.csv output.json.
FS-002CSV importRead input.csv in UTF-8/CSV-compatible format and validate header and expected columns.
FS-003Schema validationCheck mandatory fields, column count, unknown key fields and empty mandatory values.
FS-004Type conversionConvert numeric, flag and text values; invalid format is recorded as a row-level error.
FS-005Domain rule engineApply rules for Classifier Drift Monitor, including critical limits from the description and approved specification.
FS-006Status aggregationProduce final status: FAIL for critical failure, WARNING for non-critical deviation, PASS for conformance.
FS-007JSON exportWrite output.json with detailed checks, source values, warnings, failures and critical findings.
FS-008Audit supportKeep result structure suitable for review, deviation investigation and calculation reproduction.
FS-009Integration contractSupport the scenario LIMS/ELN/MES → input.csv → utility → output.json → portal/admin review.
FS-010Error handlingReturn explicit messages for missing file, empty CSV, invalid schema, output write failure and invalid format.

Example output.json

{
  "utilityId": "classifierdriftmonitor",
  "utilityFolder": "ClassifierDriftMonitor",
  "package": "LiquidBiopsy",
  "overallStatus": "PASS|WARNING|FAIL",
  "sourceFile": "input.csv",
  "processedAtUtc": "2026-06-10T00:00:00Z",
  "checks": [
    {
      "parameter": "ModelName",
      "value": "OncoClassify_v3",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-001"
    },
    {
      "parameter": "ModelVersion",
      "value": "v3.2.1",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-002"
    },
    {
      "parameter": "MonitoringWindow",
      "value": "2026-W22",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-003"
    },
    {
      "parameter": "PSI_Feature_Avg",
      "value": "0.03",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-004"
    },
    {
      "parameter": "PSI_Prediction",
      "value": "0.05",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-005"
    },
    {
      "parameter": "Max_PSI_Threshold",
      "value": "0.2",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-006"
    },
    {
      "parameter": "Warning_PSI_Threshold",
      "value": "0.1",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-007"
    },
    {
      "parameter": "KLD_Score",
      "value": "0.02",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-008"
    },
    {
      "parameter": "Max_KLD_Threshold",
      "value": "0.1",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-009"
    },
    {
      "parameter": "Prediction_Mean_Shift",
      "value": "0.01",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-010"
    },
    {
      "parameter": "Max_Mean_Shift",
      "value": "0.05",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-011"
    },
    {
      "parameter": "SampleSize_Current",
      "value": "450",
      "status": "PASS|WARNING|FAIL",
      "message": "Deterministic rule-based check result",
      "ruleReference": "FS-RULE-012"
    }
  ],
  "criticalFindings": [],
  "warnings": [],
  "audit": {
    "inputHash": "sha256:<calculated at runtime>",
    "rulesVersion": "<utility executable version>",
    "documentation": "ClassifierDriftMonitor.documentation.html"
  }
}

Traceability matrix

URSFSTestEvidence
URS-001FS-001, FS-002OQ-001Verify execution and import of valid input.csv.
URS-002FS-005, FS-006OQ-004Repeat the same dataset and compare output.json.
URS-003FS-003, FS-004, FS-010OQ-002, OQ-003Verify missing columns and invalid types.
URS-004FS-005, FS-006OQ-004, PQ-001Verify critical deviations on real/boundary data.
URS-005FS-007, FS-009OQ-005Verify JSON schema and downstream-system suitability.
URS-006FS-008OQ-006Verify identifiers and audit metadata.
URS-007FS-008, FS-010IQ-001, OQ-007Verify documentation completeness and control evidence.
URS-008FS-005, FS-008PQ-002Verify review workflow and no replacement of QA decision.

IQ/OQ/PQ test scenarios

IDScenarioExpected result
IQ-001Verify executable, input.csv, documentation and checksum availability.Delivery set is complete; version is recorded.
OQ-001Valid sample row from input.csv.PASS or acceptable WARNING according to rules.
OQ-002Remove a mandatory CSV column.Schema error or FAIL with missing-column reference.
OQ-003Place a non-numeric value into a numeric field.Type-conversion error with row/field reference.
OQ-004Set a critical parameter outside the limit.FAIL and critical finding.
OQ-005Verify output.json structure.All mandatory sections are present and JSON is valid.
OQ-006Verify batch/sample traceability.Input and result identifiers match.
PQ-001Verify 3–5 real user batches/samples.Result is confirmed by QC/QA review.
PQ-002Verify deviation workflow and manual QA decision.Utility supports review but does not replace approved decision.

QA/QC and change control

  • Do not rename columns without updating validator, documentation and test set.
  • Retain input.csv, output.json, executable version and checksum.
  • Before production use, perform IQ/OQ/PQ or equivalent CSV/CSA verification.
  • Critical limits shall be verified against the approved specification, registration dossier and local SOPs.
  • The utility provides structured QC decision support; final release decision remains with QA/QP and approved procedures.

Included in packages

Liquid Biopsy QC Suite

QC and pre-analytical control package for liquid biopsy workflows: cfDNA/ctDNA, CTC, EV/exosomes, methylation, NGS/qPCR/ddPCR, sample quality, contamination, sensitivity and reporting checks.

Open