03 — Intelligence Layer
Machine Learning Model Evaluation
Four ML approaches evaluated in strict progression — each iteration
motivated by documented failures in the previous one. Results are
honest and reproducible (random_state=42, 70/30 stratified split).
📉
Logistic Regression
APPROACH 1 · SUPERVISED BASELINE · FAILED
Simple supervised baseline to test whether linear decision
boundaries could separate attack from normal traffic. Failed on
TON_IoT because FC1–FC4 Modbus register means differ by less than 1%
between classes — no linear boundary can separate them. Partial
signal on ROSpace but inadequate recall.
solver: lbfgs
Linear boundary
TON_IoT accuracy~52% (near random)
TON_IoT F1~52%
ROSpace accuracy~81%
ROSpace recall~45% (inadequate)
verdictFailed — non-linear data
⚠️
Isolation Forest
APPROACH 2 · UNSUPERVISED · BROKEN BASELINE
Isolation Forest with contamination=0.05 hardcoded. Produced invalid
metrics due to three compounding bugs: (1) label encoding failure
converting integers to strings — all rows flagged as attacks, TN=0;
(2) label column leaked into feature matrix; (3) contamination=5% vs
actual 51.8% attack rate — model physically cannot detect most
attacks.
n_estimators: 100
contamination: 0.05 (wrong)
TON_IoT accuracy4.5% (invalid)
TON_IoT precision100% (false — TN=0)
TON_IoT recall4.5% — TN=0
verdictInvalid — 3 implementation bugs
🌲
Isolation Forest
APPROACH 3 · UNSUPERVISED CEILING · ALL BUGS FIXED
All three bugs corrected: integer labels used directly, label column
excluded from features, contamination derived from actual training
attack ratio. Reveals the true unsupervised ceiling — near-random on
TON_IoT because attack and normal Modbus register distributions are
statistically identical (mean diff < 1%). On ROSpace, flags only
29% of attacks.
n_estimators: 200
contamination: dynamic
Unsupervised
TON_IoT accuracy50.0%
TON_IoT F151.1%
ROSpace accuracy72.7%
ROSpace F129.2% (misses 70.7% of attacks)
verdictUnsupervised ceiling — insufficient
🌳
Random Forest
APPROACH 4 · SUPERVISED · FINAL PRODUCTION MODEL
Ensemble of decision trees trained on labeled data. Learns joint
feature patterns separating attack from normal — no assumption about
feature distributions. Transformative results on both datasets. Top
ROSpace features: OS memory metrics (pgfree, nr_inactive_file,
pgactivate). TON_IoT: all four FC columns contribute ~25% each,
exploiting subtle joint patterns invisible to Logistic Regression
and Isolation Forest.
Supervised
AUC-ROC 0.974 / 1.000
Production model
TON_IoT accuracy91.7%
TON_IoT F1 / Recall91.9% / 91.0%
ROSpace accuracy100.0%
ROSpace F1 / Recall99.9% / 99.8%
verdictProduction — decisively superior