xairon commited on
Commit
41bdd2c
·
verified ·
1 Parent(s): 096a8d4

Upload notebooks/01_data_exploration.ipynb with huggingface_hub

Browse files
Files changed (1) hide show
  1. notebooks/01_data_exploration.ipynb +1 -22
notebooks/01_data_exploration.ipynb CHANGED
@@ -350,28 +350,7 @@
350
  "execution_count": null,
351
  "metadata": {},
352
  "outputs": [],
353
- "source": [
354
- "# Select one representative station per major class\n",
355
- "# We pick stations with good data coverage (high nb_mois_total)\n",
356
- "TARGET_CLASSES = [\"Poreux\", \"Fissure\", \"Karstique\", \"Double porosite F+P\",\n",
357
- " \"Double porosite K+P\", \"Composite\"]\n",
358
- "\n",
359
- "example_stations = []\n",
360
- "for cls in TARGET_CLASSES:\n",
361
- " candidates = meta_labeled[\n",
362
- " (meta_labeled[\"milieu_label\"] == cls) &\n",
363
- " (meta_labeled[\"nb_mois_total\"] > meta_labeled[\"nb_mois_total\"].quantile(0.7))\n",
364
- " ].sort_values(\"nb_mois_total\", ascending=False)\n",
365
- " if len(candidates) > 0:\n",
366
- " # Pick the station closest to the median coverage in top 30%\n",
367
- " mid = len(candidates) // 2\n",
368
- " example_stations.append(candidates.iloc[mid])\n",
369
- "\n",
370
- "example_ids = [s[\"code_bss\"] for s in example_stations]\n",
371
- "print(f\"Selected {len(example_ids)} stations:\")\n",
372
- "for s in example_stations:\n",
373
- " print(f\" {s['code_bss']:20s} {s['milieu_label']:30s} ({s['nb_mois_total']} months)\")"
374
- ]
375
  },
376
  {
377
  "cell_type": "code",
 
350
  "execution_count": null,
351
  "metadata": {},
352
  "outputs": [],
353
+ "source": "# Select one representative station per major class\n# We pick stations with good data coverage (high nb_mois_total)\n# AND that exist in the time-series datasets with sufficient daily coverage\n# (metadata has ~4200 stations, but uni/multi only ~2000, some with sparse data)\nTARGET_CLASSES = [\"Poreux\", \"Fissure\", \"Karstique\", \"Double porosite F+P\",\n \"Double porosite K+P\", \"Composite\"]\n\n# Compute daily coverage per station to ensure windowing works downstream\n_station_stats = uni.dropna(subset=[\"niveau_nappe_eau\"]).groupby(\"code_bss\").agg(\n _n_valid=(\"date\", \"count\"),\n _date_min=(\"date\", \"min\"),\n _date_max=(\"date\", \"max\"),\n)\n_station_stats[\"_span_days\"] = (_station_stats[\"_date_max\"] - _station_stats[\"_date_min\"]).dt.days\n_station_stats[\"_coverage\"] = _station_stats[\"_n_valid\"] / _station_stats[\"_span_days\"].clip(lower=1)\n\n# Require 4+ years of data and >80% daily coverage\n_good_stations = set(_station_stats[\n (_station_stats[\"_span_days\"] >= 365 * 4) &\n (_station_stats[\"_coverage\"] > 0.8)\n].index)\n\nexample_stations = []\nfor cls in TARGET_CLASSES:\n candidates = meta_labeled[\n (meta_labeled[\"milieu_label\"] == cls) &\n (meta_labeled[\"code_bss\"].isin(_good_stations)) &\n (meta_labeled[\"nb_mois_total\"] > meta_labeled[\"nb_mois_total\"].quantile(0.7))\n ].sort_values(\"nb_mois_total\", ascending=False)\n if len(candidates) > 0:\n # Pick the station closest to the median coverage in top 30%\n mid = len(candidates) // 2\n example_stations.append(candidates.iloc[mid])\n\nexample_ids = [s[\"code_bss\"] for s in example_stations]\nprint(f\"Selected {len(example_ids)} stations:\")\nfor s in example_stations:\n print(f\" {s['code_bss']:20s} {s['milieu_label']:30s} ({s['nb_mois_total']} months)\")"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  },
355
  {
356
  "cell_type": "code",