Update model card: document isolation_forest.py dependency and KPIs
Browse files- model/README.md +24 -4
model/README.md
CHANGED
|
@@ -22,6 +22,25 @@ observations by randomly partitioning the feature space with binary trees; point
|
|
| 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:
|
|
@@ -41,8 +60,8 @@ the dataset for drill-down and reporting.
|
|
| 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.
|
| 45 |
-
flagged for manual review as a **high-quality-risk order**.
|
| 46 |
|
| 47 |
## Daily update strategy
|
| 48 |
|
|
@@ -67,8 +86,8 @@ the dataset for drill-down and reporting.
|
|
| 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
|
| 71 |
-
the low-risk mean delay.*
|
| 72 |
|
| 73 |
## Intended use
|
| 74 |
|
|
@@ -78,4 +97,5 @@ targeting the QIP goal of pushing the high-risk ratio below 5%.
|
|
| 78 |
## Files
|
| 79 |
|
| 80 |
- `isolation_forest_quality.joblib` — serialized model (joblib)
|
|
|
|
| 81 |
- `model_metadata.json` — training metadata, features, threshold and daily KPIs
|
|
|
|
| 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 |
+
## Loading the model (reproducible)
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
import sys, joblib
|
| 29 |
+
from huggingface_hub import hf_hub_download
|
| 30 |
+
|
| 31 |
+
# 1) put the implementation module on the path
|
| 32 |
+
sys.path.insert(0, "model") # model/isolation_forest.py
|
| 33 |
+
# (or: pip-style: download model/isolation_forest.py and import it)
|
| 34 |
+
|
| 35 |
+
# 2) download and load the serialized model
|
| 36 |
+
path = hf_hub_download("toolathon123/project_20260813_014231_9dbe9212",
|
| 37 |
+
"model/isolation_forest_quality.joblib", repo_type="dataset")
|
| 38 |
+
model = joblib.load(path) # -> isolation_forest.IsolationForest
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
`model/isolation_forest.py` is the importable source of the model class — required so the pickle can
|
| 42 |
+
resolve the `IsolationForest` class on any machine.
|
| 43 |
+
|
| 44 |
## Model inputs (features)
|
| 45 |
|
| 46 |
The model consumes the 6 numeric features of each shipment:
|
|
|
|
| 60 |
## Outputs
|
| 61 |
|
| 62 |
- **`anomaly_score`** ∈ [0.5, 1.0] — Isolation Forest anomaly score. Higher ⇒ more anomalous.
|
| 63 |
+
- **`high_risk`** ∈ {0, 1} — flag = 1 when `anomaly_score >= threshold` (0.6044), i.e.
|
| 64 |
+
the shipment is flagged for manual review as a **high-quality-risk order**.
|
| 65 |
|
| 66 |
## Daily update strategy
|
| 67 |
|
|
|
|
| 86 |
| Avg temperature deviation | 0.63 °C |
|
| 87 |
| Avg humidity deviation | 4.57 %RH |
|
| 88 |
|
| 89 |
+
*Delay improvement rate = relative reduction in mean delay if the 100 high-risk shipments
|
| 90 |
+
were remediated to the low-risk mean delay.*
|
| 91 |
|
| 92 |
## Intended use
|
| 93 |
|
|
|
|
| 97 |
## Files
|
| 98 |
|
| 99 |
- `isolation_forest_quality.joblib` — serialized model (joblib)
|
| 100 |
+
- `isolation_forest.py` — importable NumPy IsolationForest implementation
|
| 101 |
- `model_metadata.json` — training metadata, features, threshold and daily KPIs
|