Spaces:
Running
Running
Download models.py from kugguk/electrocheap: direct link, hf CLI and curl.
- Browser
- Download file 2.86 kB
-
https://huggingface.co/spaces/kugguk/electrocheap/resolve/main/models.py
- Command line
-
hf download hf://spaces/kugguk/electrocheap/models.py
-
curl -L -o models.py https://huggingface.co/spaces/kugguk/electrocheap/resolve/main/models.py
2.86 kB
| """Expose archived scores and exact versions without claiming a fresh model run.""" | |
| from pathlib import Path | |
| import hashlib | |
| import json | |
| import pandas as pd | |
| ROOT = Path(__file__).resolve().parent / "evidence/full_model_benchmark" | |
| def safe_metadata(value): | |
| # Gradio clients interpret a dictionary containing 'path' as a file object. | |
| if isinstance(value, dict): | |
| return {("source_path" if k == "path" else k): safe_metadata(v) for k,v in value.items()} | |
| if isinstance(value, list): return [safe_metadata(v) for v in value] | |
| return value | |
| def model_evidence(payload): | |
| if not isinstance(payload, dict) or payload.get("country", "PT") not in {"PT", "DE", "AU"}: | |
| raise ValueError("Supply an object with country PT, DE or AU.") | |
| country = payload.get("country", "PT") | |
| path = ROOT / "outputs/test_metrics.csv" | |
| d = pd.read_csv(path) | |
| d = d[d.country == country.lower()] | |
| records = json.loads(d.to_json(orient="records")) | |
| config = json.loads((ROOT / "foundation_config.json").read_text()) | |
| return {"status": "archived_grid_demand_evidence", "country": country, "unit": "GWh", | |
| "test_period": "2024-10 through 2026-09", "targets": 24, "forecast_horizon_months": 6, | |
| "scores_sha256": hashlib.sha256(path.read_bytes()).hexdigest(), "scores": records, | |
| "transformer_models": config["models"], "library_versions": config["environment_pins"], | |
| "tsf_source": safe_metadata(json.loads((ROOT / "vendor/forecast_lab_pro_v2/SNAPSHOT.json").read_text())), | |
| "hosted_llm": {"Astra": "gpt-6-astra", "Sol": "gpt-6.1-sol", "status": "Archived delegated test diagnostics; no live customer API configured."}, | |
| "unavailable_exact_implementations": ["Original KMLAIOps TSF SARIMAX-GARCHX", "Super Grokked (distinct source not supplied)"], | |
| "live_cpu_candidates": ["Seasonal naive", "Seasonal drift", "SARIMA", "SARIMA + frozen bias", "Grokked SARIMA · 80/20 blend", "SARIMAX · calendar", "SARIMAX + GARCH · calendar mean, residual volatility"], | |
| "bulk_live_inference": {"submit_tool":"analysis_submit","result_tool":"analysis_result","models":["seasonal_naive","sarima","grokked_sarima","sarimax_garch"],"horizon_months":"1–36","series_per_job":10,"statistical_minimum_months":36,"scope":"User-supplied complete monthly series; no grid-to-household winner transfer."}, | |
| "public_dataset_tool": "dataset_inspect", | |
| "limits": "Grid scores do not select a household forecaster or demonstrate bill savings. Transformer/LLM scores are cached evidence, not live inference. No significance claim or paid calls."} | |
| def model_table(country): | |
| r = model_evidence({"country": country}) | |
| d = pd.DataFrame(r["scores"]) | |
| return d[["model", "n", "mae_gwh", "mase", "skill_vs_seasonal_naive_pct", "selected_on_validation"]], r | |