Spaces:
Sleeping
Sleeping
File size: 2,863 Bytes
b099c5d a52ec73 b099c5d a52ec73 b099c5d a52ec73 b099c5d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
#!/usr/bin/env python
"""
Forecast Sandbox v1.0
End-to-end pipeline runner.
Runs the full sequence:
1. python -m data.prepare_data
2. python -m data.prepare_data_lgbm
3. python -m models.compute_baselines
4. python -m models.lgbm_modeling
5. python -m models.combine_metrics
6. python -m models.select_best_models
7. python -m models.generate_first_insights
8. python -m models.model_selection_audit
## SCRIPT EXECUTION DEPENDENCIES GRAPH
```
prepare_data βββΆ prepare_data_lgbm βββΆ lgbm_modeling
βββΆ compute_baselines
compute_baselines + lgbm_modeling βββΆ combine_metrics
combine_metrics βββΆ select_best_model
select_best_model βββΆ generate_first_insights
generate_first_insights βββΆ model_selection_audit
```
"""
import subprocess
import sys
from datetime import datetime
STEPS = [
("Prepare FreshNet-50K-derived train/test data", ["python", "-m", "data.prepare_data_freshnet"]),
("Prepare LightGBM training dataset", ["python", "-m", "data.prepare_data_lgbm_fresh"]),
("Compute statistical baselines", ["python", "-m", "models.compute_baselines"]),
("Train LightGBM model", ["python", "-m", "models.lgbm_modeling"]),
("Inference on Chronos2 model", ["python", "-m", "models.chronos_inference"]),
("Combine metrics", ["python", "-m", "models.combine_metrics"]),
("Select best model per SKU", ["python", "-m", "models.select_best_models"]),
("Generate first insights & plots", ["python", "-m", "models.generate_first_insights"]),
("Create model selection audit ledger", ["python", "-m", "models.model_selection_audit"]),
("Regime-conditioned forecasting analysis", ["python", "-m", "models.analysis_regime_conditioned_forecasting"])
]
def run_step(description: str, cmd: list[str]) -> None:
print(f"\n[{datetime.now().isoformat(timespec='seconds')}] βΆ {description}")
print(" Command:", " ".join(cmd))
completed = subprocess.run(cmd)
if completed.returncode != 0:
print(f"[ERROR] Step failed: {description}", file=sys.stderr)
sys.exit(completed.returncode)
print(f"[OK] {description}")
def main() -> None:
print("=== Forecast Sandbox v1.0 β Full Pipeline Run ===")
print(f"Started at: {datetime.now().isoformat(timespec='seconds')}\n")
for description, cmd in STEPS:
run_step(description, cmd)
print(f"\nFinished at: {datetime.now().isoformat(timespec='seconds')}")
print("All steps completed successfully.")
print("Key outputs:")
print(" - metrics/combined_metrics.csv")
print(" - metrics/best_by_sku.csv")
print(" - metrics/model_selection_audit.csv")
print(" - docs/model_score_ranking.png")
print(" - docs/regime_model_performance.csv")
if __name__ == "__main__":
main()
|