Agentic
od-expert skill active

Any AI Agent Becomes an OD Expert

When a user asks about anomalies in their data, PyOD's od-expert skill auto-activates. The v3.2.0 skill encodes a master decision tree, top-10 critical pitfalls, and 11 adaptive escalation triggers. The shaded panels below the agent's turns show the skill's live decision-making.

Live run on Diabetes Screening dataset (768 patients, 8 clinical features)
Layer 1: fit / predict Layer 2: ADEngine Layer 3: Agentic (v3.2.0 deep skill)
U
User
I have a diabetes screening dataset — 768 patients with 8 clinical features (glucose, blood pressure, BMI, insulin, age, etc.). Find unusual patient profiles that might need follow-up. This is a medical screening context.
A
Agent INVESTIGATE od-expert skill v3.2.0
→ Anomaly-detection intent on tabular medical data. Activating od-expert.
Profiled as tabular, low-dim, n=768, 8 features. Because this is a medical screening context, I will run the full consensus and flag the scale-mismatch caveat in the final report.
import numpy as np
from pyod.utils.ad_engine import ADEngine
np.random.seed(42)
data = np.genfromtxt('examples/data/pima.csv', delimiter=',', skip_header=1)
X = data[:, :-1]
engine = ADEngine()
state = engine.investigate(X)
Routing informed by ADBench (NeurIPS 2022): 30 algorithms on 57 tabular datasets. For n < 1000 low-dim, KNN / LOF tie with IForest in ADBench top-5.
#1 KNN K-Nearest Neighbors — proximity-based, confidence 0.85
#2 IForest Isolation Forest, ADBench top-5, confidence 0.85
#3 LOF Local Outlier Factor — local density, confidence 0.80
Running all 3 in parallel…
62
Flagged (8.1%)
0.96
Separation
0.59
Agreement
HIGH
Quality (0.79)
Top case #13 — all 3 detectors agree; consensus score 0.997 (100th percentile). KNN was the strongest individually:
DetectorRaw scorePercentile
KNN 304.13 100th
IForest 0.15 99.9th
LOF 3.41 99.8th
U
User
What clinical features are driving the flags?
A
Agent EXPLAIN
Analyzing the top anomaly (patient #13) via KNN. Absolute z-score magnitudes from engine.explain_findings:
Feature|z-score|Raw value
insulin6.65846 µU/mL
age2.1959 yrs
glucose2.13189 mg/dL
pregnancies0.841

Note: engine.explain_findings returns absolute z-score magnitudes; the raw values above are cross-checked manually to show direction. Extreme insulin (|z|=6.65), elevated glucose and older age — a metabolic-syndrome profile that warrants individual clinical review. Other top-flagged patients (#228, #247, #579, #177) each have their own contributing-feature ranking; insulin dominates several but is not a universal signature.

best_result = state.results[state.analysis['best_detector_index']]
explanations = engine.explain_findings(best_result, X=X, top_k=5)
U
User
I should mention — I actually have diabetes diagnosis labels for the full cohort.
A
Agent ESCALATE · T5
→ Trigger 5 fired: labels mentioned but not provided.
That changes the plan. Supervised detection (with your labels as training signal) typically lifts AUC 10–20 points over unsupervised on a labelled cohort like this. The ADEngine session API is unsupervised in v3.2.x, so I would drop out of the session and call XGBOD directly on the classic fit / predict path:
from pyod.models.xgbod import XGBOD
clf = XGBOD()
clf.fit(X, y_labels) # supervised
scores = clf.decision_function(X)
labels_pred = clf.predict(X)
For now, I will finalise the unsupervised report and flag the label-availability note so you can switch to XGBOD later if the labels are validated.
U
User
Just give me the report for now.
A
Agent REPORT
Diabetes Screening — Anomaly Report
Quality Assessment
Separation
0.96
Agreement
0.59
Stability
0.81

Dataset: Diabetes Screening (768 × 8)
Detectors: KNN, IForest, LOF (3 / 3 converged)
Best detector: KNN (highest correlation with consensus)
Final flagged (consensus): 62 patients (8.1%)
Diagnostics: internally consistent; validate clinically

⚠ Assumptions & caveats
• Scale mismatch: per-feature std ratio = 347×. LOF / KNN results may be biased toward the insulin axis. For a follow-up run, apply RobustScaler first.
• Contamination: default 0.1, observed 0.081 (state.analysis['consensus_analysis']['anomaly_ratio']). Close enough for unsupervised screening; adjust if you have domain knowledge.
• High-stakes domain: medical screening context triggered dual-detector validation (Pitfall 7 → always use ≥ 2 detectors). All 3 detectors independently flagged the top cases.
• Label availability: user mentioned labels exist. For labelled data, dropping out of the ADEngine session and calling XGBOD (classic fit / predict, pyod[xgboost] extra) typically lifts AUC 10–20 points over unsupervised.

Reference numbers (agent did not see ground truth): precision 33 / 62 (53.2%), recall 33 / 268 (12.3%). The low recall reflects the large contamination gap — the true positive rate is 34.9%, far above the unsupervised threshold.