1

Exploration des relations binaires

This commit is contained in:
Richard Dern 2025-11-22 01:46:57 +01:00
parent 2ff719107b
commit 1932938fd6
135 changed files with 778 additions and 136 deletions

View File

@ -4,10 +4,6 @@ On peut désormais tracer nos premiers graphiques simples et bruts.
S'ils ne sont pas très instructifs par rapport à ce que nous fournissent Home Assistant et InfluxDB, ils nous permettent au moins de nous assurer que tout fonctionne, et que les données semblent cohérentes. S'ils ne sont pas très instructifs par rapport à ce que nous fournissent Home Assistant et InfluxDB, ils nous permettent au moins de nous assurer que tout fonctionne, et que les données semblent cohérentes.
Les fichiers CSV correspondant à chaque figure sont conservés dans `data/` dans ce dossier. Les fichiers CSV correspondant à chaque figure sont conservés dans `data/` dans ce dossier.
Les graphiques couvrent maintenant toute la période disponible dans `data/weather_minutely.csv`.
Une agrégation automatique réduit le nombre de points pour rester lisible (plus de courbes "peignes"), et l'axe des dates utilise un format compact qui évite tout chevauchement de labels.
On peut au besoin restreindre la période avec `--days` ou imposer une fréquence d'agrégation avec `--resample`.
```shell ```shell
python "docs/03 - Premiers graphiques/scripts/plot_basic_variables.py" python "docs/03 - Premiers graphiques/scripts/plot_basic_variables.py"
``` ```
@ -30,9 +26,6 @@ python "docs/03 - Premiers graphiques/scripts/plot_basic_variables.py"
## Vues calendrier ## Vues calendrier
Les vues calendrier permettent de visualiser, jour par jour, les cumuls ou moyennes quotidiennes sur la dernière année complète disponible.
Les images générées sont stockées dans `figures/calendar/` et les CSV correspondants dans `data/calendar/`.
```shell ```shell
python "docs/03 - Premiers graphiques/scripts/plot_calendar_overview.py" python "docs/03 - Premiers graphiques/scripts/plot_calendar_overview.py"
``` ```
@ -48,5 +41,3 @@ python "docs/03 - Premiers graphiques/scripts/plot_calendar_overview.py"
![](figures/calendar/calendar_illuminance_2025.png) ![](figures/calendar/calendar_illuminance_2025.png)
![](figures/calendar/calendar_wind_2025.png) ![](figures/calendar/calendar_wind_2025.png)
Ces vues, bien que simples en principe, mettent déjà mieux en évidence les fluctuations au cours du temps.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 432 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 610 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 587 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 445 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 430 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 KiB

View File

@ -60,74 +60,18 @@ python "docs/04 - Corrélations binaires/scripts/plot_pairwise_time_series.py"
![](figures/pairwise_timeseries/timeseries_wind_direction_vs_sun_elevation.png) ![](figures/pairwise_timeseries/timeseries_wind_direction_vs_sun_elevation.png)
## Nuages de points
```shell
python "docs/04 - Corrélations binaires/scripts/plot_all_pairwise_scatter.py"
```
![](figures/pairwise_scatter/scatter_humidity_vs_illuminance.png)
![](figures/pairwise_scatter/scatter_humidity_vs_pressure.png)
![](figures/pairwise_scatter/scatter_humidity_vs_rain_rate.png)
![](figures/pairwise_scatter/scatter_humidity_vs_sun_elevation.png)
![](figures/pairwise_scatter/scatter_humidity_vs_wind_direction.png)
![](figures/pairwise_scatter/scatter_humidity_vs_wind_speed.png)
![](figures/pairwise_scatter/scatter_illuminance_vs_sun_elevation.png)
![](figures/pairwise_scatter/scatter_illuminance_vs_wind_direction.png)
![](figures/pairwise_scatter/scatter_illuminance_vs_wind_speed.png)
![](figures/pairwise_scatter/scatter_pressure_vs_illuminance.png)
![](figures/pairwise_scatter/scatter_pressure_vs_rain_rate.png)
![](figures/pairwise_scatter/scatter_pressure_vs_sun_elevation.png)
![](figures/pairwise_scatter/scatter_pressure_vs_wind_direction.png)
![](figures/pairwise_scatter/scatter_pressure_vs_wind_speed.png)
![](figures/pairwise_scatter/scatter_rain_rate_vs_illuminance.png)
![](figures/pairwise_scatter/scatter_rain_rate_vs_sun_elevation.png)
![](figures/pairwise_scatter/scatter_rain_rate_vs_wind_direction.png)
![](figures/pairwise_scatter/scatter_rain_rate_vs_wind_speed.png)
![](figures/pairwise_scatter/scatter_temperature_vs_humidity.png)
![](figures/pairwise_scatter/scatter_temperature_vs_illuminance.png)
![](figures/pairwise_scatter/scatter_temperature_vs_pressure.png)
![](figures/pairwise_scatter/scatter_temperature_vs_rain_rate.png)
![](figures/pairwise_scatter/scatter_temperature_vs_sun_elevation.png)
![](figures/pairwise_scatter/scatter_temperature_vs_wind_direction.png)
![](figures/pairwise_scatter/scatter_temperature_vs_wind_speed.png)
![](figures/pairwise_scatter/scatter_wind_direction_vs_sun_elevation.png)
![](figures/pairwise_scatter/scatter_wind_speed_vs_sun_elevation.png)
![](figures/pairwise_scatter/scatter_wind_speed_vs_wind_direction.png)
## Matrices de corrélation (instantané, signé) ## Matrices de corrélation (instantané, signé)
Le calcul des coefficients de Pearson et de Spearman peut nous donner une indication numérique des corrélations entre les différentes variables.
Cette information peut nous aiguiller sur des relations spécifiques (ou au contraire, nous induire en erreur...).
```shell ```shell
python "docs/04 - Corrélations binaires/scripts/plot_correlation_heatmap.py" --transform absolute --upper-only python "docs/04 - Corrélations binaires/scripts/plot_correlation_heatmap.py" --transform=identity --upper-only
``` ```
![](figures/correlation_heatmap_abs.png) ![](figures/correlation_heatmap.png)
![](figures/correlation_heatmap_spearman_abs.png) ![](figures/correlation_heatmap_spearman.png)
Le signe et l'intensité des coefficients montrent à quel point deux variables bougent ensemble au même instant (co-mouvement linéaire pour Pearson, monotone pour Spearman).
Cette matrice sert donc surtout de carte globale : repérer rapidement les couples très corrélés ou indiquer un lien physique évident, mettre en alerte des variables à forte corrélation qui pourraient masquer d'autres effets (saisonnalité, cycle jour/nuit), et choisir quelles paires méritent qu'on teste des décalages temporels ou des relations non linéaires dans la suite.

View File

@ -1,52 +0,0 @@
# scripts/plot_all_pairwise_scatter.py
from __future__ import annotations
from pathlib import Path
import sys
PROJECT_ROOT = Path(__file__).resolve().parents[3]
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
from meteo.dataset import load_raw_csv
from meteo.variables import iter_variable_pairs
from meteo.plots import plot_scatter_pair
CSV_PATH = Path("data/weather_minutely.csv")
DOC_DIR = Path(__file__).resolve().parent.parent
OUTPUT_DIR = DOC_DIR / "figures" / "pairwise_scatter"
def main() -> None:
if not CSV_PATH.exists():
print(f"⚠ Fichier introuvable : {CSV_PATH}")
return
df = load_raw_csv(CSV_PATH)
print(f"Dataset minuté chargé : {CSV_PATH}")
print(f" Lignes : {len(df)}")
print(f" Colonnes : {list(df.columns)}")
pairs = iter_variable_pairs()
print(f"Nombre de paires de variables : {len(pairs)}")
for var_x, var_y in pairs:
filename = f"scatter_{var_x.key}_vs_{var_y.key}.png"
output_path = OUTPUT_DIR / filename
print(f"→ Trace {var_y.key} en fonction de {var_x.key}{output_path}")
plot_scatter_pair(
df=df,
var_x=var_x,
var_y=var_y,
output_path=output_path,
sample_step=10, # un point sur 10 : ≈ 32k points au lieu de 320k
)
print("✔ Tous les graphiques de nuages de points ont été générés.")
if __name__ == "__main__":
main()

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Some files were not shown because too many files have changed in this diff Show More