-
Notifications
You must be signed in to change notification settings - Fork 920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor/metrics #2284
Refactor/metrics #2284
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #2284 +/- ##
==========================================
- Coverage 93.95% 93.91% -0.04%
==========================================
Files 136 137 +1
Lines 13687 13962 +275
==========================================
+ Hits 12860 13113 +253
- Misses 827 849 +22 ☔ View full report in Codecov by Sentry. |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
… metrics, pre computed hist fcs, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The metrics look so much tidier now!
Some minor comments, mostly about documentation.
Checklist before merging this PR:
Fixes #2249, fixes #2233, closes #2031.
Summary
merr()
(Mean Error)rmsse()
, andmsse()
: The (Root) Mean Squared Scaled Error.err()
(Error),ae()
(Absolute Error),se()
(Squared Error),sle()
(Squared Log Error),ase()
(Absolute Scaled Error),sse
(Squared Scaled Error),ape()
(Absolute Percentage Error),sape()
(symmetric Absolute Percentage Error),arre()
(Absolute Ranged Relative Error),ql
(Quantile Loss)insample
series that can be overlapping intopred_series
(before that had to end exactly one step beforepred_series
). Darts will handle the correct time extraction for you.series
, and the applied reductions:float
: A single metric score for:component_reduction
series_reduction
andcomponent_reduction
(andtime_reduction
for "per time step metrics")np.ndarray
: A numpy array of metric scores. The array has shape (n time steps, n components) without time and component reductions. The time dimension is only available for "per time step" metrics. For:component_reduction=None
for time aggregated metrics.time_reduction=None
for "per time step metrics"series_reduction
and at least one ofcomponent_reduction=None
ortime_reduction=None
for "per time step metrics"List[float]
: Same as for typefloat
but for a sequence of seriesList[np.ndarray]
Same as for typenp.ndarray
but for a sequence of seriesquantile_loss()
:mql()
(Mean Quantile Loss)tau
toq
2
to make the loss more interpretable (e.g. forq=0.5
it is identical to theMAE
)rho_risk()
:qr()
(Quantile Risk)rho
toq
reduction
toseries_reduction
inter_reduction
tocomponent_reduction
m=None
.multi_ts_support
andmultivariate_support
must now act on multivariate series (possibly containing missing values) instead of univariate series.ForecastingModel.historical_forecasts()
:series
: Ifseries
is a sequence, historical forecasts will always return a sequence/list of the same length (instead of trying to reduce to aTimeSeries
object).TimeSeries
: A single historical forecast for a singleseries
andlast_points_only=True
: it contains only the predictions at stepforecast_horizon
from all historical forecasts.List[TimeSeries]
A list of historical forecasts for:series
andlast_points_only=True
: for each series, it contains only the predictions at stepforecast_horizon
from all historical forecasts.series
andlast_points_only=False
: for each historical forecast, it contains the entire horizonforecast_horizon
.List[List[TimeSeries]]
A list of lists of historical forecasts for a sequence ofseries
andlast_points_only=False
. For each series, and historical forecast, it contains the entire horizonforecast_horizon
. The outer list is over the series provided in the input sequence, and the inner lists contain the historical forecasts for each series.ForecastingModel.backtest()
:series
andhistorical_forecasts
, significantly speeding things up when using a large number ofseries
.metric
(such asase
,mase
, ...). No extra code required, backtest extracts the correctinsample
series for you.metric_kwargs
. This allows for example parallelization of the metric computation withn_jobs
, customize the metric reduction with*_reduction
, specify seasonalitym
for scaled metrics, etc..series
,historical_forecast
, and the applied backtest reduction:float
: A single backtest score for single uni/multivariate series, a singlemetric
function and:historical_forecasts
generated withlast_points_only=True
historical_forecasts
generated withlast_points_only=False
and using a backtestreduction
np.ndarray
: An numpy array of backtest scores. For single series and one of:metric
function,historical_forecasts
generated withlast_points_only=False
and backtestreduction=None
. The output has shape (n forecasts,).metric
functions andhistorical_forecasts
generated withlast_points_only=False
. The output has shape (n metrics,) when using a backtestreduction
, and (n metrics, n forecasts) whenreduction=None
series_reduction
and at least one ofcomponent_reduction=None
ortime_reduction=None
for "per time step metrics"List[float]
: Same as for typefloat
but for a sequence of series. The returned metric list has lengthlen(series)
with thefloat
metric for each inputseries
.List[np.ndarray]
Same as for typenp.ndarray
but for a sequence of series. The returned metric list has lengthlen(series)
with thenp.ndarray
metrics for each inputseries
.reduction
callable now acts onaxis=1
rather thanaxis=0
to aggregate the metrics per series.historical_forecasts
don't have the expected format based on inputseries
and thelast_points_only
value.ForecastingModel.residuals()
. While the default behavior ofresiduals()
remains identical, the method is now very similar tobacktest()
but that it computes a "per time step"metric
onhistorical_forecasts
:series
.historical_forecasts()
parameters to generate the historical forecasts for the residuals computation.historical_forecasts
.metric
(e.g.err()
,ae()
,ape()
, ...). By default useserr()
(Error).n_jobs
.series
andhistorical_forecast
:TimeSeries
: ResidualTimeSeries
for a singleseries
andhistorical_forecasts
generated withlast_points_only=True
.List[TimeSeries]
A list of residualTimeSeries
for a sequence (list) ofseries
withlast_points_only=True
. The residual list has lengthlen(series)
.List[List[TimeSeries]]
A list of lists of residualTimeSeries
for a sequence ofseries
withlast_points_only=False
. The outer residual list has lengthlen(series)
. The inner lists consist of the residuals from all possible series-specific historical forecasts.TimeSeries
:(https://github.com/dennisbader).slice_intersect()
,has_same_time_as()
slice_intersect_values()
, which returns the sliced values of a series, where the time index has been intersected with another series.generate_index()
fromdarts.utils.timeseries_generation
todarts.utils.utils
retain_period_common_to_all()
,series2seq()
,seq2series()
,get_single_series()
fromdarts.utils.utils
todarts.utils.ts_utils
.Here are the speed ups for different series lengths and number of components: