Skip to content

Commit b41be28

Browse files
authored
Feat/metrics quantiles (unit8co#2530)
1 parent 67d4dbd commit b41be28

File tree

13 files changed

+1929
-199
lines changed

13 files changed

+1929
-199
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ but cannot always guarantee backwards compatibility. Changes that may **break co
1111

1212
**Improved**
1313

14-
- Added `IQRDetector`, that allows to detect anomalies using the interquartile range algorithm. [#2441] by [Igor Urbanik](https://github.com/u8-igor).
14+
- Added `IQRDetector`, that allows to detect anomalies using the interquartile range algorithm. [#2441](https://github.com/unit8co/darts/issues/2441) by [Igor Urbanik](https://github.com/u8-igor).
1515
- Added hyperparameters controlling the hidden layer sizes for the feature encoders in `TiDEModel`. [#2408](https://github.com/unit8co/darts/issues/2408) by [eschibli](https://github.com/eschibli).
1616
- Added hyperparameter `activation` to `BlockRNNModel` to specify the activation function in case of a multi-layer output network. [#2408](https://github.com/unit8co/darts/issues/2408) by [eschibli](https://github.com/eschibli).
1717
- Added support for broadcasting to TimeSeries on component and sample level. [#2476](https://https://github.com/unit8co/darts/pull/2476) by [Joel L.](https://github.com/Joelius300).
18+
- Added support for computing metrics, backtest, and residuals on one or multiple quantiles `q`, either from probabilistic predictions or predicted quantiles. [#2530](https://github.com/unit8co/darts/issues/2530) by [Dennis Bader](https://github.com/dennisbader).
19+
- Added quantile interval metrics: `miw` (Mean Interval Width, time aggregated) and `iw` (Interval Width, per time step / non-aggregated) which compute the width of quantile intervals `q_intervals` (expected to be a tuple or sequence of tuples with (lower quantile, upper quantile). [#2530](https://github.com/unit8co/darts/issues/2530) by [Dennis Bader](https://github.com/dennisbader).
20+
- Added property `TimeSeries.shape` to get the shape of the time series. [#2530](https://github.com/unit8co/darts/issues/2530) by [Dennis Bader](https://github.com/dennisbader).
21+
- Added support for parameters `enable_optimization` and `predict_likelihood_parameters` to the forecasting models' `backtest()` and `residuals()` methods. [#2530](https://github.com/unit8co/darts/issues/2530) by [Dennis Bader](https://github.com/dennisbader).
1822
- Helper function `darts.utils.utils.generate_index()` now accepts datetime strings as `start` and `end` parameters to generate the pandas DatetimeIndex. [#2522](https://github.com/unit8co/darts/pull/2522) by [Dennis Bader](https://github.com/dennisbader).
1923
- Various improvements in the documentation:
2024
- Made README's forecasting model support table more colorblind-friendly. [#2433](https://github.com/unit8co/darts/pull/2433)

darts/ad/anomaly_model/forecasting_am.py

+5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def fit(
132132
`train_length`.
133133
enable_optimization
134134
Whether to use the optimized version of historical_forecasts when supported and available.
135+
Default: ``True``.
135136
model_fit_kwargs
136137
Parameters to be passed on to the forecast model `fit()` method.
137138
@@ -212,6 +213,7 @@ def score(
212213
`train_length`.
213214
enable_optimization
214215
Whether to use the optimized version of historical_forecasts when supported and available.
216+
Default: ``True``.
215217
return_model_prediction
216218
Whether to return the forecasting model prediction along with the anomaly scores.
217219
@@ -299,6 +301,7 @@ def predict_series(
299301
`train_length`.
300302
enable_optimization
301303
Whether to use the optimized version of historical_forecasts when supported and available.
304+
Default: ``True``.
302305
303306
Returns
304307
-------
@@ -394,6 +397,7 @@ def eval_metric(
394397
`train_length`.
395398
enable_optimization
396399
Whether to use the optimized version of historical_forecasts when supported and available.
400+
Default: ``True``.
397401
metric
398402
The name of the metric function to use. Must be one of "AUC_ROC" (Area Under the
399403
Receiver Operating Characteristic Curve) and "AUC_PR" (Average Precision from scores).
@@ -499,6 +503,7 @@ def show_anomalies(
499503
`train_length`.
500504
enable_optimization
501505
Whether to use the optimized version of historical_forecasts when supported and available.
506+
Default: ``True``.
502507
anomalies
503508
The ground truth of the anomalies (1 if it is an anomaly and 0 if not).
504509
names_of_scorers

darts/metrics/__init__.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
Metrics
33
-------
44
5-
For deterministic forecasts (point predictions with `num_samples == 1`):
5+
For deterministic forecasts (point predictions with `num_samples == 1`), probabilistic forecasts (`num_samples > 1`),
6+
and quantile forecasts. For probablistic and quantile forecasts, use parameter `q` to define the quantile(s) to
7+
compute the deterministic metrics on:
8+
69
- Aggregated over time:
710
Absolute metrics:
811
- :func:`MERR <darts.metrics.metrics.merr>`: Mean Error
@@ -42,8 +45,10 @@
4245
- Aggregated over time:
4346
- :func:`MQL <darts.metrics.metrics.mql>`: Mean Quantile Loss
4447
- :func:`QR <darts.metrics.metrics.qr>`: Quantile Risk
48+
- :func:`MIW <darts.metrics.metrics.miw>`: Mean Interval Width
4549
- Per time step:
4650
- :func:`QL <darts.metrics.metrics.ql>`: Quantile Loss
51+
- :func:`IW <darts.metrics.metrics.iw>`: Interval Width
4752
4853
For Dynamic Time Warping (DTW) (aggregated over time):
4954
- :func:`DTW <darts.metrics.metrics.dtw_metric>`: Dynamic Time Warping Metric
@@ -57,11 +62,13 @@
5762
coefficient_of_variation,
5863
dtw_metric,
5964
err,
65+
iw,
6066
mae,
6167
mape,
6268
marre,
6369
mase,
6470
merr,
71+
miw,
6572
mql,
6673
mse,
6774
msse,
@@ -90,6 +97,7 @@
9097
se,
9198
sle,
9299
sse,
100+
iw,
93101
}
94102

95103
__all__ = [
@@ -120,4 +128,6 @@
120128
"sle",
121129
"smape",
122130
"sse",
131+
"iw",
132+
"miw",
123133
]

0 commit comments

Comments
 (0)