toolathon123 commited on
Commit
b603bb9
·
verified ·
1 Parent(s): 73b2483

Update model card with 2026-08-13 details

Browse files
Files changed (1) hide show
  1. model/README.md +54 -90
model/README.md CHANGED
@@ -1,117 +1,81 @@
1
  ---
2
- language:
3
- - pt
4
- - es
5
- - en
6
- language_bcp47:
7
- - pt-BR
8
- - es-AR
9
- - en
10
- library_name: scikit-learn
11
  tags:
12
  - anomaly-detection
13
  - isolation-forest
14
  - logistics
15
- - transport-quality
16
- - quality-improvement
 
17
  license: apache-2.0
18
- datasets:
19
- - toolathon123/project_20260813_014231_9dbe9212
20
- metrics:
21
- - high_risk_ratio
22
- - average_delay_improvement
23
- model-index:
24
- - name: isolation_forest_quality
25
- results: []
26
  ---
27
 
28
- # Isolation Forest — High-Risk Transport Order Detector
29
 
30
- **Model file:** `isolation_forest_quality.joblib`
31
- **Companion metadata:** `model_metadata.json`
32
- **Repo:** [`toolathon123/project_20260813_014231_9dbe9212`](https://huggingface.co/datasets/toolathon123/project_20260813_014231_9dbe9212)
 
33
 
34
- ## Model description
 
 
 
35
 
36
- A lightweight unsupervised **anomaly-detection model** (scikit-learn `IsolationForest`) that flags
37
- **high-risk transport orders** in the South American logistics network (Brazil / Argentina / Uruguay / Chile).
38
- It isolates atypical shipments whose quality profile deviates from the daily fleet baseline — e.g. excessive
39
- border delay, cargo damage, cold-chain drift on Argentine agri-produce, abnormal fuel burn, or low composite
40
- quality score.
41
 
42
- ## Input features (numeric)
43
 
44
- The model consumes **6 numeric features** extracted from each shipment record:
 
 
 
 
 
 
 
45
 
46
- | Feature | Meaning |
47
- |---------|---------|
48
- | `delay_minutes` | Arrival delay (minutes) |
49
- | `damage_flag` | 1 = cargo damaged, 0 = intact |
50
- | `temperature_deviation` | Abs. deviation from target temp (deg C) |
51
- | `humidity_deviation` | Abs. deviation from target RH (%) |
52
- | `fuel_consumption` | Total fuel consumed (litres) |
53
- | `quality_score` | Composite quality score (0–100) |
54
 
55
- No scaling is applied — IsolationForest is tree-based and scale-invariant.
56
 
57
- ## Output meaning
58
-
59
- - `predict()` `-1`: **HIGH-RISK** order (anomaly), `1`: normal.
60
- - `decision_function()` → **score**: higher = more normal, lower = more anomalous.
61
- - `contamination = 0.10`: the model is calibrated to surface the worst ~10% of orders as high-risk.
62
-
63
- ## Training data
64
-
65
- - Snapshot: **2026-08-12** (1,500 shipments), `train` split of the dataset repo.
66
- - Trained: **2026-08-13** via the QIP daily pipeline.
67
 
68
  ## Daily update strategy
69
 
70
- 1. Every operational day the new parquet snapshot is appended to the dataset `train` split (see dataset card).
71
- 2. The pipeline re-trains `IsolationForest` on the day's records (seeded, reproducible).
72
- 3. The new `model/isolation_forest_quality.joblib` + `model_metadata.json` are uploaded to this repo,
73
- replacing the previous version (history kept in git/LFS revisions).
74
- 4. KPIs (high-risk ratio, mean delay, delay improvement vs. trailing baseline) are recomputed and logged.
 
75
 
76
- ## Daily quality metrics (2026-08-12 snapshot)
77
 
78
  | Metric | Value |
79
  |--------|-------|
80
- | High-risk orders | 150 / 1,500 |
81
- | **High-risk order ratio** | **10.0%** |
82
- | Mean delay today | 104.83 min |
83
- | Baseline (trailing 7-day) mean delay | 118.00 min |
84
- | **Avg. delay improvement rate** | **11.16%** |
85
- | Damage rate | 11.8% |
86
- | Avg temperature deviation | 1.017 °C |
87
- | Avg humidity deviation | 5.12 %RH |
88
- | Avg quality score | 54.18 |
 
 
 
89
 
90
  ## Intended use
91
 
92
- - **Risk triage:** operations team reviews the flagged ~10% high-risk orders for re-planning, border slot
93
- booking and reefer pre-calibration.
94
- - **Trend monitoring:** daily re-run supports the QIP targets (high-risk < 5%, border delay -15%,
95
- cold-chain deviations -20%, wet-season damage -10%, fuel -10%).
96
- - **Reproducibility:** pinned `scikit-learn` version and seeded training make each day's model reproducible.
97
-
98
- ## Load and use
99
-
100
- ```python
101
- import joblib
102
- from huggingface_hub import hf_hub_download
103
-
104
- path = hf_hub_download(
105
- "toolathon123/project_20260813_014231_9dbe9212",
106
- "model/isolation_forest_quality.joblib",
107
- repo_type="dataset",
108
- )
109
- model = joblib.load(path)
110
- # features order:
111
- FEATURES = ["delay_minutes", "damage_flag", "temperature_deviation",
112
- "humidity_deviation", "fuel_consumption", "quality_score"]
113
- # model.predict(X) -> -1 high-risk / 1 normal
114
- ```
115
 
116
- ---
117
- *Maintained by the São Paulo QIP team — daily anomaly scoring pipeline.*
 
 
 
1
  ---
2
+ library_name: sklearn
 
 
 
 
 
 
 
 
3
  tags:
4
  - anomaly-detection
5
  - isolation-forest
6
  - logistics
7
+ - quality
8
+ - risk-scoring
9
+ pipeline_tag: tabular-classification
10
  license: apache-2.0
 
 
 
 
 
 
 
 
11
  ---
12
 
13
+ # Isolation Forest — Daily Transport Quality Risk Model
14
 
15
+ > **Model:** `isolation_forest_quality.joblib`
16
+ > **Task:** unsupervised anomaly detection on daily shipment-quality records
17
+ > **Training date:** 2026-08-13
18
+ > **Dataset:** `toolathon123/project_20260813_014231_9dbe9212` (2,000 shipments)
19
 
20
+ Pure **NumPy implementation of an Isolation Forest** (Liu, Ting & Zhou, 2008). The algorithm isolates
21
+ observations by randomly partitioning the feature space with binary trees; points that are *easy to isolate*
22
+ (i.e. require few splits) are anomalous. Because scikit-learn is not installed in the pipeline runtime, the
23
+ model is shipped as a self-contained `joblib` blob with no external runtime dependency beyond NumPy.
24
 
25
+ ## Model inputs (features)
 
 
 
 
26
 
27
+ The model consumes the 6 numeric features of each shipment:
28
 
29
+ | # | Feature | Description |
30
+ |---|---------|-------------|
31
+ | 1 | `delay_minutes` | Arrival delay in minutes |
32
+ | 2 | `damage_flag` | 1 if cargo damaged, else 0 |
33
+ | 3 | `temperature_deviation` | Deviation from target temperature (°C) |
34
+ | 4 | `humidity_deviation` | Deviation from target relative humidity (%RH) |
35
+ | 5 | `fuel_consumption` | Total fuel consumed (litres) |
36
+ | 6 | `quality_score` | Composite quality score 0–100 |
37
 
38
+ Categorical fields (`route`, `carrier`, `origin`, `destination`) are not used for scoring; they are kept in
39
+ the dataset for drill-down and reporting.
 
 
 
 
 
 
40
 
41
+ ## Outputs
42
 
43
+ - **`anomaly_score`** ∈ [0.5, 1.0] — Isolation Forest anomaly score. Higher ⇒ more anomalous.
44
+ - **`high_risk`** ∈ {0, 1} — flag = 1 when `anomaly_score >= threshold` (0.6044), i.e. the shipment is
45
+ flagged for manual review as a **high-quality-risk order**.
 
 
 
 
 
 
 
46
 
47
  ## Daily update strategy
48
 
49
+ - The model is **retrained every operational day** on that day's fresh `train` snapshot
50
+ (`data/train-*.parquet`).
51
+ - Hyper-parameters: `n_estimators=100`, `max_samples=256`, `contamination=0.05` (anomaly threshold = 95th
52
+ percentile of training anomaly scores).
53
+ - `model_metadata.json` stores the trained thresholds, feature list and the day's KPIs for full traceability
54
+ and comparison across days.
55
 
56
+ ## Performance / daily KPIs (2026-08-13)
57
 
58
  | Metric | Value |
59
  |--------|-------|
60
+ | High-risk order ratio | 5.00% (100 / 2000) |
61
+ | Avg delay (all shipments) | 83.2 min |
62
+ | Avg delay (low-risk) | 77.4 min |
63
+ | Avg delay (high-risk) | 192.7 min |
64
+ | **Avg delay improvement rate** | **6.93%** |
65
+ | Damage rate | 8.10% |
66
+ | Avg quality score | 85.52 |
67
+ | Avg temperature deviation | 0.63 °C |
68
+ | Avg humidity deviation | 4.57 %RH |
69
+
70
+ *Delay improvement rate = relative reduction in mean delay if the 100 high-risk shipments were remediated to
71
+ the low-risk mean delay.*
72
 
73
  ## Intended use
74
 
75
+ Operational daily triage: prioritise manual inspection and re-planning for the top high-risk shipments,
76
+ targeting the QIP goal of pushing the high-risk ratio below 5%.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
+ ## Files
79
+
80
+ - `isolation_forest_quality.joblib` — serialized model (joblib)
81
+ - `model_metadata.json` — training metadata, features, threshold and daily KPIs