import numpy as np
from spotforecast2_safe.forecaster.metrics import crps_from_predictions
y_true = 5.0
y_pred = np.array([4.5, 5.1, 4.9, 5.3, 4.7])
crps = crps_from_predictions(y_true, y_pred)
print(crps >= 0)True
Compute the Continuous Ranked Probability Score (CRPS) from predictions.
The CRPS compares the empirical distribution of a set of forecasted values to a scalar observation. The smaller the CRPS, the better.
| Name | Type | Description | Default |
|---|---|---|---|
| y_true | float | The true value of the random variable. | required |
| y_pred | np.ndarray | The predicted values of the random variable. These are the multiple forecasted values for a single observation. | required |
| Name | Type | Description |
|---|---|---|
| float | The CRPS score. |