expected greenness v2-ca
Browse files- .gitattributes +1 -0
- README.md +35 -0
- climatology.parquet +3 -0
- conformal.json +22 -0
- feature_schema.json +57 -0
- golden/expected.parquet +3 -0
- golden/inputs.parquet +3 -0
- metrics.json +175 -0
- model_ca.ubj +3 -0
- model_v2_ca.yaml +78 -0
- predict_ca.py +75 -0
- weather_climatology.parquet +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
model_ca.ubj filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
library_name: xgboost
|
| 4 |
+
tags: [nasa, modis, ndvi, imerg, gldas, pastures, central-asia, tabular-regression]
|
| 5 |
+
datasets: [TrendeX90/ca-cube]
|
| 6 |
+
---
|
| 7 |
+
# TrendeX expected greenness, Central Asia (v2-ca)
|
| 8 |
+
|
| 9 |
+
Summer (May-Sep) NDVI anomaly of 1 km pasture cells in Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan and
|
| 10 |
+
Uzbekistan, predicted from weather (IMERG precipitation; GLDAS air temperature, soil moisture, snow) and terrain
|
| 11 |
+
only. The gap to observed NDVI is change **not explained by weather**: not a cause, not forage quality.
|
| 12 |
+
Protocol locked in git before fitting (`model_v2_ca.yaml`, commit 1bc6ed3). Naryn pilot model: TrendeX90/expected-greenness (v1).
|
| 13 |
+
|
| 14 |
+
| Test | RMSE xgb | RMSE ridge | RMSE climatology | anomaly corr xgb |
|
| 15 |
+
|---|---|---|---|---|
|
| 16 |
+
| Temporal (2020-2025) | 0.0530 | 0.0546 | 0.0613 | 0.510 |
|
| 17 |
+
| Spatial (unseen super-blocks) | 0.0483 | 0.0515 | 0.0592 | 0.578 |
|
| 18 |
+
|
| 19 |
+
- Skill vs ridge: temporal 0.055 (95% CI 0.036 to 0.077, 6 units); spatial 0.120 (95% CI 0.117 to 0.123, 4115 units).
|
| 20 |
+
- Skill vs climatology: temporal 0.251 (95% CI 0.174 to 0.321, 6 units).
|
| 21 |
+
- Seeds (3): 0.053 +/- 0.001.
|
| 22 |
+
- **Gate (pre-registered, CI lower bound > 0 on both tests): passed = True; shipped = xgb.**
|
| 23 |
+
- P10-P90 coverage on 2020-2025: 76% (nominal 80%).
|
| 24 |
+
|
| 25 |
+
Limits: trained on 150,000 sampled cells (of 3,432,538 eligible) because of budget; GLDAS
|
| 26 |
+
(0.25 deg) is coarse; MCD12Q1 2020 mask; NDVI is greenness, not forage; no field validation; budget-limited tuning
|
| 27 |
+
(20 trials) and 3 seeds. Spatial test shares years with training and is easier than the temporal test.
|
| 28 |
+
|
| 29 |
+
```python
|
| 30 |
+
from predict_ca import load # numpy, pandas, xgboost; CPU
|
| 31 |
+
m = load(".")
|
| 32 |
+
m.predict(features_df) # columns as in feature_schema.json
|
| 33 |
+
```
|
| 34 |
+
Data: MOD13A3.061, MCD12Q1.061, NASADEM_HGT.001 (LP DAAC), GPM_3IMERGM.07, GLDAS_NOAH025_M.2.1 (GES DISC).
|
| 35 |
+
AI use: implementation assisted by Claude (Anthropic).
|
climatology.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ab533e03e82e4d6ab3bbfd78610306badbcbbd3a4c263ee36218b4087dec96d
|
| 3 |
+
size 129245489
|
conformal.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"5": [
|
| 3 |
+
-0.06532957404851913,
|
| 4 |
+
0.07366171479225159
|
| 5 |
+
],
|
| 6 |
+
"6": [
|
| 7 |
+
-0.05224672704935074,
|
| 8 |
+
0.058576423674821854
|
| 9 |
+
],
|
| 10 |
+
"7": [
|
| 11 |
+
-0.041381578892469406,
|
| 12 |
+
0.05795556306838989
|
| 13 |
+
],
|
| 14 |
+
"8": [
|
| 15 |
+
-0.03494373336434364,
|
| 16 |
+
0.05861777812242508
|
| 17 |
+
],
|
| 18 |
+
"9": [
|
| 19 |
+
-0.03975394368171692,
|
| 20 |
+
0.05265418812632561
|
| 21 |
+
]
|
| 22 |
+
}
|
feature_schema.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"elev_mean",
|
| 4 |
+
"elev_std",
|
| 5 |
+
"slope_mean",
|
| 6 |
+
"steep_share",
|
| 7 |
+
"aspect_sin",
|
| 8 |
+
"aspect_cos",
|
| 9 |
+
"tpi",
|
| 10 |
+
"grass_frac",
|
| 11 |
+
"barren_frac",
|
| 12 |
+
"crop_frac",
|
| 13 |
+
"lc_type1",
|
| 14 |
+
"lat",
|
| 15 |
+
"month",
|
| 16 |
+
"clim_ndvi",
|
| 17 |
+
"precip_m",
|
| 18 |
+
"precip_2m",
|
| 19 |
+
"precip_winter",
|
| 20 |
+
"tair_m",
|
| 21 |
+
"tair_prev",
|
| 22 |
+
"soil_m",
|
| 23 |
+
"swe_apr"
|
| 24 |
+
],
|
| 25 |
+
"static": [
|
| 26 |
+
"elev_mean",
|
| 27 |
+
"elev_std",
|
| 28 |
+
"slope_mean",
|
| 29 |
+
"steep_share",
|
| 30 |
+
"aspect_sin",
|
| 31 |
+
"aspect_cos",
|
| 32 |
+
"tpi",
|
| 33 |
+
"grass_frac",
|
| 34 |
+
"barren_frac",
|
| 35 |
+
"crop_frac",
|
| 36 |
+
"lc_type1",
|
| 37 |
+
"lat"
|
| 38 |
+
],
|
| 39 |
+
"weather": [
|
| 40 |
+
"precip_m",
|
| 41 |
+
"precip_2m",
|
| 42 |
+
"precip_winter",
|
| 43 |
+
"tair_m",
|
| 44 |
+
"tair_prev",
|
| 45 |
+
"soil_m",
|
| 46 |
+
"swe_apr"
|
| 47 |
+
],
|
| 48 |
+
"months": [
|
| 49 |
+
5,
|
| 50 |
+
6,
|
| 51 |
+
7,
|
| 52 |
+
8,
|
| 53 |
+
9
|
| 54 |
+
],
|
| 55 |
+
"shipped_model": "xgb",
|
| 56 |
+
"target": "ndvi_anomaly = ndvi - clim_ndvi"
|
| 57 |
+
}
|
golden/expected.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c0e910ef315e50a00c42088376b7873987e6c9fe58402a0bda1855f4d92ea2a2
|
| 3 |
+
size 5213
|
golden/inputs.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b76f2d3ee138de052cf42b49131d75fb1259529db70b13069d95036c86f662de
|
| 3 |
+
size 16270
|
metrics.json
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"protocol": "configs/model_v2_ca.yaml",
|
| 3 |
+
"git_commit": "1bc6ed3",
|
| 4 |
+
"features": [
|
| 5 |
+
"elev_mean",
|
| 6 |
+
"elev_std",
|
| 7 |
+
"slope_mean",
|
| 8 |
+
"steep_share",
|
| 9 |
+
"aspect_sin",
|
| 10 |
+
"aspect_cos",
|
| 11 |
+
"tpi",
|
| 12 |
+
"grass_frac",
|
| 13 |
+
"barren_frac",
|
| 14 |
+
"crop_frac",
|
| 15 |
+
"lc_type1",
|
| 16 |
+
"lat",
|
| 17 |
+
"month",
|
| 18 |
+
"clim_ndvi",
|
| 19 |
+
"precip_m",
|
| 20 |
+
"precip_2m",
|
| 21 |
+
"precip_winter",
|
| 22 |
+
"tair_m",
|
| 23 |
+
"tair_prev",
|
| 24 |
+
"soil_m",
|
| 25 |
+
"swe_apr"
|
| 26 |
+
],
|
| 27 |
+
"data": {
|
| 28 |
+
"eligible_cells": 3432538,
|
| 29 |
+
"sample_cells": 150000,
|
| 30 |
+
"by_country_eligible": {
|
| 31 |
+
"KAZ": 2757030,
|
| 32 |
+
"UZB": 225373,
|
| 33 |
+
"TKM": 219350,
|
| 34 |
+
"KGZ": 162550,
|
| 35 |
+
"TJK": 68235
|
| 36 |
+
}
|
| 37 |
+
},
|
| 38 |
+
"tuning": {
|
| 39 |
+
"trials": 20,
|
| 40 |
+
"best_params": {
|
| 41 |
+
"max_depth": 4,
|
| 42 |
+
"learning_rate": 0.10100846649096142,
|
| 43 |
+
"min_child_weight": 2.1372740576773146,
|
| 44 |
+
"subsample": 0.972334458524792,
|
| 45 |
+
"colsample_bytree": 0.7609241608750359,
|
| 46 |
+
"reg_lambda": 0.07186075653512951
|
| 47 |
+
},
|
| 48 |
+
"n_estimators": 189,
|
| 49 |
+
"inner_rmse_xgb": 0.05189208313822746,
|
| 50 |
+
"ridge_alpha": 10000,
|
| 51 |
+
"inner_rmse_ridge": {
|
| 52 |
+
"1": 0.05240725725889206,
|
| 53 |
+
"10": 0.05240725725889206,
|
| 54 |
+
"100": 0.05240722745656967,
|
| 55 |
+
"1000": 0.0524069219827652,
|
| 56 |
+
"10000": 0.05240388959646225
|
| 57 |
+
}
|
| 58 |
+
},
|
| 59 |
+
"temporal_test": {
|
| 60 |
+
"n_rows": 4488859,
|
| 61 |
+
"xgb": {
|
| 62 |
+
"rmse": 0.05302759259939194,
|
| 63 |
+
"mae": 0.03565985709428787,
|
| 64 |
+
"anomaly_corr": 0.5099059549633065,
|
| 65 |
+
"tercile_bacc": 0.5443049159397115
|
| 66 |
+
},
|
| 67 |
+
"ridge": {
|
| 68 |
+
"rmse": 0.05455656722187996,
|
| 69 |
+
"mae": 0.0374000109732151,
|
| 70 |
+
"anomaly_corr": 0.4676613138043512,
|
| 71 |
+
"tercile_bacc": 0.514210718924312
|
| 72 |
+
},
|
| 73 |
+
"clim": {
|
| 74 |
+
"rmse": 0.061273232102394104,
|
| 75 |
+
"mae": 0.04196174815297127,
|
| 76 |
+
"anomaly_corr": null,
|
| 77 |
+
"tercile_bacc": 0.3333333333333333
|
| 78 |
+
},
|
| 79 |
+
"skill_xgb_vs_ridge": {
|
| 80 |
+
"point": 0.05526524782180786,
|
| 81 |
+
"ci_lo": 0.03597217798233032,
|
| 82 |
+
"ci_hi": 0.07688862085342407,
|
| 83 |
+
"units": 6
|
| 84 |
+
},
|
| 85 |
+
"skill_xgb_vs_clim": {
|
| 86 |
+
"point": 0.2510329484939575,
|
| 87 |
+
"ci_lo": 0.1736202985048294,
|
| 88 |
+
"ci_hi": 0.32145172357559204,
|
| 89 |
+
"units": 6
|
| 90 |
+
},
|
| 91 |
+
"skill_ridge_vs_clim": {
|
| 92 |
+
"point": 0.20721977949142456,
|
| 93 |
+
"ci_lo": 0.13052883744239807,
|
| 94 |
+
"ci_hi": 0.2746666967868805,
|
| 95 |
+
"units": 6
|
| 96 |
+
},
|
| 97 |
+
"seed_skill_vs_ridge": {
|
| 98 |
+
"values": [
|
| 99 |
+
0.05177319049835205,
|
| 100 |
+
0.05277097225189209,
|
| 101 |
+
0.05364823341369629
|
| 102 |
+
],
|
| 103 |
+
"mean": 0.05273079872131348,
|
| 104 |
+
"sd": 0.0007660099729616311
|
| 105 |
+
},
|
| 106 |
+
"conformal_coverage_p10_p90": 0.7649012811496195
|
| 107 |
+
},
|
| 108 |
+
"spatial_test": {
|
| 109 |
+
"n_rows": 18704206,
|
| 110 |
+
"xgb": {
|
| 111 |
+
"rmse": 0.048309534788131714,
|
| 112 |
+
"mae": 0.03170231729745865,
|
| 113 |
+
"anomaly_corr": 0.5783080677059781,
|
| 114 |
+
"tercile_bacc": 0.5685434390166627
|
| 115 |
+
},
|
| 116 |
+
"ridge": {
|
| 117 |
+
"rmse": 0.05148749053478241,
|
| 118 |
+
"mae": 0.03450145572423935,
|
| 119 |
+
"anomaly_corr": 0.4926088947138233,
|
| 120 |
+
"tercile_bacc": 0.5289723245865422
|
| 121 |
+
},
|
| 122 |
+
"clim": {
|
| 123 |
+
"rmse": 0.05916392803192139,
|
| 124 |
+
"mae": 0.04005257412791252,
|
| 125 |
+
"anomaly_corr": null,
|
| 126 |
+
"tercile_bacc": 0.3333333333333333
|
| 127 |
+
},
|
| 128 |
+
"skill_xgb_vs_ridge": {
|
| 129 |
+
"point": 0.11963582038879395,
|
| 130 |
+
"ci_lo": 0.11683060228824615,
|
| 131 |
+
"ci_hi": 0.12261748313903809,
|
| 132 |
+
"units": 4115
|
| 133 |
+
},
|
| 134 |
+
"skill_xgb_vs_clim": {
|
| 135 |
+
"point": 0.3332679867744446,
|
| 136 |
+
"ci_lo": 0.3277331292629242,
|
| 137 |
+
"ci_hi": 0.3389349579811096,
|
| 138 |
+
"units": 4115
|
| 139 |
+
},
|
| 140 |
+
"skill_ridge_vs_clim": {
|
| 141 |
+
"point": 0.24266338348388672,
|
| 142 |
+
"ci_lo": 0.23721951246261597,
|
| 143 |
+
"ci_hi": 0.24812857806682587,
|
| 144 |
+
"units": 4115
|
| 145 |
+
}
|
| 146 |
+
},
|
| 147 |
+
"gate": {
|
| 148 |
+
"rule": "CI lower bound of skill_xgb_vs_ridge > 0 on temporal AND spatial tests",
|
| 149 |
+
"passed": true,
|
| 150 |
+
"shipped_model": "xgb"
|
| 151 |
+
},
|
| 152 |
+
"feature_importance_mean_abs": {
|
| 153 |
+
"precip_2m": 0.012883000075817108,
|
| 154 |
+
"precip_winter": 0.01007699966430664,
|
| 155 |
+
"soil_m": 0.00824899971485138,
|
| 156 |
+
"precip_m": 0.006624000146985054,
|
| 157 |
+
"tair_prev": 0.0029460000805556774,
|
| 158 |
+
"clim_ndvi": 0.002933999989181757,
|
| 159 |
+
"swe_apr": 0.0013470000121742487,
|
| 160 |
+
"lat": 0.0012919999426230788,
|
| 161 |
+
"tair_m": 0.0012839999981224537,
|
| 162 |
+
"month": 0.0010100000072270632,
|
| 163 |
+
"elev_mean": 0.0007680000271648169,
|
| 164 |
+
"slope_mean": 0.0002300000051036477,
|
| 165 |
+
"grass_frac": 0.0002099999983329326,
|
| 166 |
+
"elev_std": 7.899999764049426e-05,
|
| 167 |
+
"steep_share": 2.4000000848900527e-05,
|
| 168 |
+
"crop_frac": 1.4000000192027073e-05,
|
| 169 |
+
"lc_type1": 7.000000096013537e-06,
|
| 170 |
+
"aspect_sin": 0.0,
|
| 171 |
+
"aspect_cos": 0.0,
|
| 172 |
+
"tpi": 0.0,
|
| 173 |
+
"barren_frac": 0.0
|
| 174 |
+
}
|
| 175 |
+
}
|
model_ca.ubj
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:910f58c42bbafbbc7ed717d8ab5073a8225bb951a0aee2b77c9da13e561929bc
|
| 3 |
+
size 324910
|
model_v2_ca.yaml
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TrendeX expected-greenness for Central Asia, protocol v2-ca.
|
| 2 |
+
# Locked BEFORE the first fit (git). Differs from v1 (Naryn) only where the CA data force it; listed below.
|
| 3 |
+
# Budget constraint: the whole run must fit the remaining Vast credit, hence the smaller tuning/seed budget.
|
| 4 |
+
|
| 5 |
+
name: expected-greenness-ca
|
| 6 |
+
version: v2-ca
|
| 7 |
+
question: >
|
| 8 |
+
How much of each pasture cell's summer greenness anomaly in Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan and
|
| 9 |
+
Uzbekistan is explained by weather (IMERG precipitation, GLDAS air temperature, soil moisture, snow) and terrain?
|
| 10 |
+
Residual = change not explained by weather (never called a cause).
|
| 11 |
+
|
| 12 |
+
data:
|
| 13 |
+
cube: TrendeX90/ca-cube
|
| 14 |
+
cells: mask_reason is null # excludes water, ice, urban, too_steep (>35 deg), barren, cropland, forest
|
| 15 |
+
months: [5, 6, 7, 8, 9]
|
| 16 |
+
years: [2001, 2025]
|
| 17 |
+
target_rows: ndvi_ok == true
|
| 18 |
+
training_sample: {cells: 150000, sampling: uniform random over eligible cells, seed: 0}
|
| 19 |
+
prediction: every eligible cell (out-of-fold, see cross_fit)
|
| 20 |
+
|
| 21 |
+
target:
|
| 22 |
+
name: ndvi_anomaly
|
| 23 |
+
definition: ndvi - clim(cell, month)
|
| 24 |
+
climatology: training years of the current split only; leave-own-year-out for training rows
|
| 25 |
+
|
| 26 |
+
features:
|
| 27 |
+
static: [elev_mean, elev_std, slope_mean, steep_share, aspect_sin, aspect_cos, tpi, grass_frac, barren_frac, crop_frac, lc_type1, lat]
|
| 28 |
+
calendar: [month]
|
| 29 |
+
climatology: [clim_ndvi]
|
| 30 |
+
weather_anomalies: # value - 2001-2025 mean of the same cell and month
|
| 31 |
+
- precip_m # IMERG, this month
|
| 32 |
+
- precip_2m # this + previous month (Apr available for May)
|
| 33 |
+
- precip_winter # Oct (previous year) .. Mar sum
|
| 34 |
+
- tair_m # GLDAS air temperature, this month
|
| 35 |
+
- tair_prev # previous month
|
| 36 |
+
- soil_m # GLDAS 0-10 cm soil moisture
|
| 37 |
+
- swe_apr # GLDAS snow water equivalent in April
|
| 38 |
+
changes_vs_v1:
|
| 39 |
+
- "MODIS LST/snow replaced by GLDAS tair/swe (MODIS 8-day products for all of CA are too large for the budget)"
|
| 40 |
+
- "precip_3m -> precip_2m (the CA cube keeps Apr-Oct only); winter window Oct-Mar instead of Oct-Apr"
|
| 41 |
+
- "lat added as a static feature: the region spans 35-55 N, so latitude carries day length / season length; x/lon and year still excluded"
|
| 42 |
+
- "crop_frac added as a static feature"
|
| 43 |
+
excluded_on_purpose: [year, lon, x, y, any NDVI lag]
|
| 44 |
+
|
| 45 |
+
splits:
|
| 46 |
+
temporal_test: {train: [2001, 2019], test: [2020, 2025]}
|
| 47 |
+
spatial_test: {kind: GroupKFold, folds: 5, group: superblock_33x33_cells}
|
| 48 |
+
cross_fit_for_residuals: {kind: contiguous_year_blocks, blocks: [[2001, 2005], [2006, 2010], [2011, 2015], [2016, 2020], [2021, 2025]]}
|
| 49 |
+
inner_validation_for_tuning: {train: [2001, 2015], valid: [2016, 2019]}
|
| 50 |
+
|
| 51 |
+
baselines:
|
| 52 |
+
B0_climatology: anomaly = 0
|
| 53 |
+
B1_ridge: Ridge on the same standardized features, alpha chosen on the inner split
|
| 54 |
+
|
| 55 |
+
model:
|
| 56 |
+
kind: xgboost
|
| 57 |
+
params_fixed: {tree_method: hist, device: cuda, objective: "reg:squarederror"}
|
| 58 |
+
tuning: {sampler: optuna_tpe, max_minutes: 10, max_trials: 20}
|
| 59 |
+
seeds: [0, 1, 2]
|
| 60 |
+
|
| 61 |
+
metrics:
|
| 62 |
+
primary: skill_vs_ridge = 1 - MSE_model / MSE_ridge
|
| 63 |
+
others: [rmse, mae, skill_vs_climatology, anomaly_correlation, tercile_balanced_accuracy]
|
| 64 |
+
uncertainty: {temporal: bootstrap over test years, spatial: bootstrap over superblocks, resamples: 2000}
|
| 65 |
+
|
| 66 |
+
gate:
|
| 67 |
+
rule: ship xgboost only if the 95% CI lower bound of skill_vs_ridge > 0 on BOTH temporal and spatial tests
|
| 68 |
+
otherwise: ship ridge and say so
|
| 69 |
+
|
| 70 |
+
intervals: {method: split conformal on inner-split residuals per month, levels: [0.1, 0.9], check: coverage on temporal test}
|
| 71 |
+
|
| 72 |
+
residual_trends:
|
| 73 |
+
series: summer (Jun-Aug) mean of out-of-fold residuals per cell and year; residual referenced to the all-years cell climatology
|
| 74 |
+
test: trend.py trend_1d (Hamed-Rao), copied unchanged from the backend
|
| 75 |
+
multiple_testing: Benjamini-Hochberg across cells, q < 0.05
|
| 76 |
+
min_years: 18
|
| 77 |
+
placebo: 200 permutations on a 200,000-cell random subsample
|
| 78 |
+
aggregates: [block, region (ADM1), country]
|
predict_ca.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""TrendeX expected greenness, Central Asia (v2-ca): CPU inference. Imports only numpy, pandas, xgboost.
|
| 2 |
+
|
| 3 |
+
Files next to this module: model_ca.ubj, feature_schema.json, climatology.parquet (cell_id, month, clim_ndvi),
|
| 4 |
+
weather_climatology.parquet (cell_id, month, <feature>_mean), conformal.json.
|
| 5 |
+
|
| 6 |
+
from predict_ca import load
|
| 7 |
+
m = load("path/to/repo")
|
| 8 |
+
m.predict(df) # df has feature_schema.json columns
|
| 9 |
+
m.what_if(cells, cell_ids, month=7, precip_pct=-30, temp_c=1) # cells = ca-cube cells.parquet rows
|
| 10 |
+
|
| 11 |
+
Expected greenness from weather and terrain alone; the gap to observed NDVI is change NOT explained by
|
| 12 |
+
precipitation, air temperature, snow and soil moisture. Not a cause, not forage quality.
|
| 13 |
+
"""
|
| 14 |
+
from __future__ import annotations
|
| 15 |
+
|
| 16 |
+
import json
|
| 17 |
+
from pathlib import Path
|
| 18 |
+
|
| 19 |
+
import numpy as np
|
| 20 |
+
import pandas as pd
|
| 21 |
+
import xgboost as xgb
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class ExpectedGreennessCA:
|
| 25 |
+
def __init__(self, root):
|
| 26 |
+
root = Path(root)
|
| 27 |
+
s = json.loads((root / "feature_schema.json").read_text())
|
| 28 |
+
self.features, self.static, self.weather = s["features"], s["static"], s["weather"]
|
| 29 |
+
self.booster = xgb.Booster()
|
| 30 |
+
self.booster.load_model(str(root / "model_ca.ubj"))
|
| 31 |
+
self.booster.set_param({"device": "cpu"})
|
| 32 |
+
self.clim = pd.read_parquet(root / "climatology.parquet").set_index(["cell_id", "month"])
|
| 33 |
+
self.wclim = pd.read_parquet(root / "weather_climatology.parquet").set_index(["cell_id", "month"])
|
| 34 |
+
self.conf = {int(k): v for k, v in json.loads((root / "conformal.json").read_text()).items()}
|
| 35 |
+
|
| 36 |
+
def predict(self, df: pd.DataFrame) -> pd.DataFrame:
|
| 37 |
+
missing = [c for c in self.features if c not in df.columns]
|
| 38 |
+
if missing:
|
| 39 |
+
raise ValueError(f"missing features: {missing}")
|
| 40 |
+
X = df[self.features].to_numpy(dtype="float32")
|
| 41 |
+
pred = self.booster.predict(xgb.DMatrix(X, feature_names=self.features))
|
| 42 |
+
months = df["month"].astype(int).to_numpy()
|
| 43 |
+
lo = np.array([self.conf[m][0] for m in months])
|
| 44 |
+
hi = np.array([self.conf[m][1] for m in months])
|
| 45 |
+
exp = df["clim_ndvi"].to_numpy() + pred
|
| 46 |
+
return pd.DataFrame({"pred_anom": pred, "expected": exp, "p10": exp + lo, "p90": exp + hi}, index=df.index)
|
| 47 |
+
|
| 48 |
+
def what_if(self, cells: pd.DataFrame, cell_ids, month: int, precip_pct: float = 0.0, temp_c: float = 0.0,
|
| 49 |
+
soil_pct: float = 0.0) -> pd.DataFrame:
|
| 50 |
+
ids = np.asarray(cell_ids)
|
| 51 |
+
key = pd.MultiIndex.from_arrays([ids, np.full(len(ids), int(month))])
|
| 52 |
+
w = self.wclim.reindex(key)
|
| 53 |
+
st = cells.set_index("cell_id").reindex(ids)
|
| 54 |
+
|
| 55 |
+
def frame(pp, tc, sp):
|
| 56 |
+
f = pd.DataFrame({k: st[k].to_numpy() for k in self.static})
|
| 57 |
+
f["month"] = float(month)
|
| 58 |
+
f["clim_ndvi"] = self.clim["clim_ndvi"].reindex(key).to_numpy()
|
| 59 |
+
for k in ("precip_m", "precip_2m", "precip_winter"):
|
| 60 |
+
f[k] = w[f"{k}_mean"].to_numpy() * pp / 100.0
|
| 61 |
+
f["tair_m"] = f["tair_prev"] = tc
|
| 62 |
+
f["soil_m"] = w["soil_m_mean"].to_numpy() * sp / 100.0
|
| 63 |
+
f["swe_apr"] = 0.0
|
| 64 |
+
return f
|
| 65 |
+
|
| 66 |
+
res = self.predict(frame(precip_pct, temp_c, soil_pct))
|
| 67 |
+
base = self.predict(frame(0.0, 0.0, 0.0))
|
| 68 |
+
res.insert(0, "cell_id", ids)
|
| 69 |
+
res["expected_typical_weather"] = base["expected"].to_numpy()
|
| 70 |
+
res["change_vs_typical"] = res["expected"].to_numpy() - base["expected"].to_numpy()
|
| 71 |
+
return res
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def load(root=Path(__file__).parent) -> ExpectedGreennessCA:
|
| 75 |
+
return ExpectedGreennessCA(root)
|
weather_climatology.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:46f9a27624a482bfc4f6198d1225cb9c42474ad7e452b1774782eb9d1137ce18
|
| 3 |
+
size 615030013
|