Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/user-guide/plotting.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```

Expand Down
11 changes: 7 additions & 4 deletions src/modelskill/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
--------
Expand Down
Loading