| --- |
| library_name: sklearn |
| tags: |
| - anomaly-detection |
| - isolation-forest |
| - logistics |
| - quality |
| - risk-scoring |
| pipeline_tag: tabular-classification |
| license: apache-2.0 |
| --- |
| |
| # Isolation Forest — Daily Transport Quality Risk Model |
|
|
| > **Model:** `isolation_forest_quality.joblib` |
| > **Task:** unsupervised anomaly detection on daily shipment-quality records |
| > **Training date:** 2026-08-13 |
| > **Dataset:** `toolathon123/project_20260813_014231_9dbe9212` (2,000 shipments) |
| |
| Pure **NumPy implementation of an Isolation Forest** (Liu, Ting & Zhou, 2008). The algorithm isolates |
| observations by randomly partitioning the feature space with binary trees; points that are *easy to isolate* |
| (i.e. require few splits) are anomalous. Because scikit-learn is not installed in the pipeline runtime, the |
| model is shipped as a self-contained `joblib` blob with no external runtime dependency beyond NumPy. |
| |
| ## Model inputs (features) |
| |
| The model consumes the 6 numeric features of each shipment: |
| |
| | # | Feature | Description | |
| |---|---------|-------------| |
| | 1 | `delay_minutes` | Arrival delay in minutes | |
| | 2 | `damage_flag` | 1 if cargo damaged, else 0 | |
| | 3 | `temperature_deviation` | Deviation from target temperature (°C) | |
| | 4 | `humidity_deviation` | Deviation from target relative humidity (%RH) | |
| | 5 | `fuel_consumption` | Total fuel consumed (litres) | |
| | 6 | `quality_score` | Composite quality score 0–100 | |
|
|
| Categorical fields (`route`, `carrier`, `origin`, `destination`) are not used for scoring; they are kept in |
| the dataset for drill-down and reporting. |
|
|
| ## Outputs |
|
|
| - **`anomaly_score`** ∈ [0.5, 1.0] — Isolation Forest anomaly score. Higher ⇒ more anomalous. |
| - **`high_risk`** ∈ {0, 1} — flag = 1 when `anomaly_score >= threshold` (0.6044), i.e. the shipment is |
| flagged for manual review as a **high-quality-risk order**. |
|
|
| ## Daily update strategy |
|
|
| - The model is **retrained every operational day** on that day's fresh `train` snapshot |
| (`data/train-*.parquet`). |
| - Hyper-parameters: `n_estimators=100`, `max_samples=256`, `contamination=0.05` (anomaly threshold = 95th |
| percentile of training anomaly scores). |
| - `model_metadata.json` stores the trained thresholds, feature list and the day's KPIs for full traceability |
| and comparison across days. |
|
|
| ## Performance / daily KPIs (2026-08-13) |
|
|
| | Metric | Value | |
| |--------|-------| |
| | High-risk order ratio | 5.00% (100 / 2000) | |
| | Avg delay (all shipments) | 83.2 min | |
| | Avg delay (low-risk) | 77.4 min | |
| | Avg delay (high-risk) | 192.7 min | |
| | **Avg delay improvement rate** | **6.93%** | |
| | Damage rate | 8.10% | |
| | Avg quality score | 85.52 | |
| | Avg temperature deviation | 0.63 °C | |
| | Avg humidity deviation | 4.57 %RH | |
|
|
| *Delay improvement rate = relative reduction in mean delay if the 100 high-risk shipments were remediated to |
| the low-risk mean delay.* |
|
|
| ## Intended use |
|
|
| Operational daily triage: prioritise manual inspection and re-planning for the top high-risk shipments, |
| targeting the QIP goal of pushing the high-risk ratio below 5%. |
|
|
| ## Files |
|
|
| - `isolation_forest_quality.joblib` — serialized model (joblib) |
| - `model_metadata.json` — training metadata, features, threshold and daily KPIs |
|
|