Reinforcement Learning
stable-baselines3
deep-reinforcement-learning
agricultural-ai
weather-modelling
curriculum-learning
edge-ai
Instructions to use DHDRL/monsoon-rl with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- stable-baselines3
How to use DHDRL/monsoon-rl with stable-baselines3:
from huggingface_sb3 import load_from_hub checkpoint = load_from_hub( repo_id="DHDRL/monsoon-rl", filename="{MODEL FILENAME}.zip", ) - Notebooks
- Google Colab
- Kaggle
Update evaluate_checkpoint_real.py
Browse files- evaluate_checkpoint_real.py +29 -2
evaluate_checkpoint_real.py
CHANGED
|
@@ -389,6 +389,33 @@ def group_points_by_date(
|
|
| 389 |
# Decision policies
|
| 390 |
# ---------------------------------------------------------------------------
|
| 391 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
def decide_scorer_oracle(
|
| 393 |
obs: ZoneObs,
|
| 394 |
fc: ForecastResult,
|
|
@@ -463,7 +490,7 @@ def decide_checkpoint(
|
|
| 463 |
loop_product, loop_elevated = product, elevated
|
| 464 |
rs = None
|
| 465 |
try:
|
| 466 |
-
rs =
|
| 467 |
rs_product = is_product_actionable(rs, gate)
|
| 468 |
_PATH_CHECK_N += 1
|
| 469 |
if rs_product != loop_product:
|
|
@@ -491,7 +518,7 @@ def decide_zero_inspect(
|
|
| 491 |
believed_p = _initial_belief_from_info(info, ctx.config)
|
| 492 |
rs = None
|
| 493 |
try:
|
| 494 |
-
rs =
|
| 495 |
except Exception:
|
| 496 |
pass
|
| 497 |
return product, elevated, rs, 1, believed_p, initial_belief
|
|
|
|
| 389 |
# Decision policies
|
| 390 |
# ---------------------------------------------------------------------------
|
| 391 |
|
| 392 |
+
def _multi_zone_risk_score(ctx: EpisodeContext) -> RiskScore:
|
| 393 |
+
"""Risk score for a (possibly multi-zone) EpisodeContext, matching
|
| 394 |
+
WeatherForecastEnv._compute_multi_zone_risk(): the zone with the
|
| 395 |
+
highest supply_shortfall_prob across ALL zones in the episode, not
|
| 396 |
+
just ctx.obs/ctx.forecast (which points_to_multi_zone_episode always
|
| 397 |
+
sets to zone_ids[0] alone).
|
| 398 |
+
|
| 399 |
+
ctx.obs/ctx.forecast is only ever a single zone's data by construction
|
| 400 |
+
(see points_to_multi_zone_episode / point_to_episode). For single-zone
|
| 401 |
+
episodes this is identical to compute_risk_score(ctx.obs, ctx.forecast,
|
| 402 |
+
ctx.config); for multi-zone episodes it must aggregate across
|
| 403 |
+
ctx.resolved_zone_obs()/ctx.resolved_zone_forecasts() the same way the
|
| 404 |
+
env does, or "rs" silently stops representing the same decision as the
|
| 405 |
+
env's actual per-step product_actionable flag.
|
| 406 |
+
"""
|
| 407 |
+
zone_obs = ctx.resolved_zone_obs()
|
| 408 |
+
zone_fc = ctx.resolved_zone_forecasts()
|
| 409 |
+
best: Optional[RiskScore] = None
|
| 410 |
+
for zo, zf in zip(zone_obs, zone_fc):
|
| 411 |
+
score = compute_risk_score(zo, zf, ctx.config)
|
| 412 |
+
if best is None or score.supply_shortfall_prob > best.supply_shortfall_prob:
|
| 413 |
+
best = score
|
| 414 |
+
return best if best is not None else compute_risk_score(
|
| 415 |
+
ctx.obs, ctx.forecast, ctx.config
|
| 416 |
+
)
|
| 417 |
+
|
| 418 |
+
|
| 419 |
def decide_scorer_oracle(
|
| 420 |
obs: ZoneObs,
|
| 421 |
fc: ForecastResult,
|
|
|
|
| 490 |
loop_product, loop_elevated = product, elevated
|
| 491 |
rs = None
|
| 492 |
try:
|
| 493 |
+
rs = _multi_zone_risk_score(ctx)
|
| 494 |
rs_product = is_product_actionable(rs, gate)
|
| 495 |
_PATH_CHECK_N += 1
|
| 496 |
if rs_product != loop_product:
|
|
|
|
| 518 |
believed_p = _initial_belief_from_info(info, ctx.config)
|
| 519 |
rs = None
|
| 520 |
try:
|
| 521 |
+
rs = _multi_zone_risk_score(ctx)
|
| 522 |
except Exception:
|
| 523 |
pass
|
| 524 |
return product, elevated, rs, 1, believed_p, initial_belief
|