From c4b4836ca49df61df9d16509690306603cedfa07 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Thu, 22 Oct 2026 08:06:56 +0200 Subject: [PATCH 1/2] Clarify that r2 is the coefficient of determination, not cc squared The docstring called r2 the proportion of explained variance, which is ev. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/modelskill/metrics.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modelskill/metrics.py b/src/modelskill/metrics.py index 5d0652666..0a8bcb74d 100644 --- a/src/modelskill/metrics.py +++ b/src/modelskill/metrics.py @@ -311,7 +311,9 @@ def kge(obs: ArrayLike, model: ArrayLike) -> Any: def r2(obs: ArrayLike, model: ArrayLike) -> Any: r"""Coefficient of determination (R2) - Pronounced 'R-squared'; the proportion of the variation in the dependent variable that is predictable from the independent variable(s), i.e. the proportion of explained variance. + Same value as Nash-Sutcliffe efficiency and scikit-learn's `r2_score`. + Not squared Pearson correlation (`cc**2`): r2 penalises bias and amplitude + errors, and is negative when the model is worse than the observed mean. $$ R^2 = 1 - \frac{\sum_{i=1}^n (model_i - obs_i)^2} @@ -320,9 +322,10 @@ def r2(obs: ArrayLike, model: ArrayLike) -> Any: Range: $(-\infty, 1]$; Best: 1 - Notes - ----- - r2 = nash_sutcliffe_efficiency(nse) + See Also + -------- + nash_sutcliffe_efficiency + cc Examples -------- From 07ef7dea42849bae1eed8c8275c4899aea3e1dc5 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Thu, 22 Oct 2026 08:53:43 +0200 Subject: [PATCH 2/2] Pass measured columns first in the wind_rose example The example passed the model first, so the legend labelled it Measurement. Co-Authored-By: Claude Opus 5.5 (1M context) --- docs/user-guide/plotting.qmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/plotting.qmd b/docs/user-guide/plotting.qmd index 4ded728d7..fa7598206 100644 --- a/docs/user-guide/plotting.qmd +++ b/docs/user-guide/plotting.qmd @@ -135,12 +135,12 @@ The radial distance from the point to the observation point is the standard devi ## Directional data (e.g. wind or currents) -Directional data can be plotted using the [`wind_rose`](`modelskill.plotting.wind_rose`). The function takes an array-like structure with speed and direction as columns (from one or two sources) and plots a wind rose: +Directional data can be plotted using the [`wind_rose`](`modelskill.plotting.wind_rose`). The function takes an array-like structure with speed and direction as columns (from one or two sources) and plots a wind rose. With two sources, the first pair is labelled "Measurement" and the second "Model" (see `labels`): ```{python} import mikeio ds = mikeio.read("../data/wave_dir.dfs0") -df = ds[[0,2,1,3]].to_dataframe() +df = ds[[1,3,0,2]].to_dataframe() # measured speed, direction, then model df.round(2).head() ```