# Metrics¶

Some metrics to compare time series.

darts.metrics.metrics.coefficient_of_variation(actual_series, pred_series, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

Coefficient of Variation (percentage).

Given a time series of actual values $$y_t$$ and a time series of predicted values $$\hat{y}_t$$, it is a percentage value, computed as

$100 \cdot \text{RMSE}(y_t, \hat{y}_t) / \bar{y_t},$

where $$\text{RMSE}()$$ denotes the root mean squared error, and $$\bar{y_t}$$ is the average of $$y_t$$.

Currently this only supports deterministic series (made of one sample).

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Returns

The Coefficient of Variation

Return type

float

darts.metrics.metrics.dtw_metric(actual_series, pred_series, metric=<function mae>, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False, **kwargs)[source]

Applies Dynamic Time Warping to actual_series and pred_series before passing it into the metric. Enables comparison between series of different lengths, phases and time indices.

Defaults to using mae as a metric.

See darts.dataprocessing.dtw.dtw for more supported parameters.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• metric (Callable[[Union[TimeSeries, Sequence[TimeSeries]], Union[TimeSeries, Sequence[TimeSeries]]], Union[float, ndarray]]) – The selected metric with signature ‘[[TimeSeries, TimeSeries], float]’ to use. Default: mae.

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Returns

Result of calling metric(warped_series1, warped_series2)

Return type

float

darts.metrics.metrics.mae(actual_series, pred_series, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

Mean Absolute Error (MAE).

For two time series $$y^1$$ and $$y^2$$ of length $$T$$, it is computed as

$\frac{1}{T}\sum_{t=1}^T{(|y^1_t - y^2_t|)}.$

If any of the series is stochastic (containing several samples), the median sample value is considered.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Returns

The Mean Absolute Error (MAE)

Return type

float

darts.metrics.metrics.mape(actual_series, pred_series, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

Mean Absolute Percentage Error (MAPE).

Given a time series of actual values $$y_t$$ and a time series of predicted values $$\hat{y}_t$$ both of length $$T$$, it is a percentage value computed as

$100 \cdot \frac{1}{T} \sum_{t=1}^{T}{\left| \frac{y_t - \hat{y}_t}{y_t} \right|}.$

Note that it will raise a ValueError if $$y_t = 0$$ for some $$t$$. Consider using the Mean Absolute Scaled Error (MASE) in these cases.

If any of the series is stochastic (containing several samples), the median sample value is considered.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Raises

ValueError – If the actual series contains some zeros.

Returns

The Mean Absolute Percentage Error (MAPE)

Return type

float

darts.metrics.metrics.marre(actual_series, pred_series, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

Mean Absolute Ranged Relative Error (MARRE).

Given a time series of actual values $$y_t$$ and a time series of predicted values $$\hat{y}_t$$ both of length $$T$$, it is a percentage value computed as

$100 \cdot \frac{1}{T} \sum_{t=1}^{T} {\left| \frac{y_t - \hat{y}_t} {\max_t{y_t} - \min_t{y_t}} \right|}$

If any of the series is stochastic (containing several samples), the median sample value is considered.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Raises

ValueError – If $$\max_t{y_t} = \min_t{y_t}$$.

Returns

The Mean Absolute Ranged Relative Error (MARRE)

Return type

float

darts.metrics.metrics.mase(actual_series, pred_series, insample, m=1, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

Mean Absolute Scaled Error (MASE).

See Mean absolute scaled error wikipedia page for details about the MASE and how it is computed.

If any of the series is stochastic (containing several samples), the median sample value is considered.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• insample (Union[TimeSeries, Sequence[TimeSeries]]) – The training series used to forecast pred_series . This series serves to compute the scale of the error obtained by a naive forecaster on the training data.

• m (Optional[int]) – Optionally, the seasonality to use for differencing. m=1 corresponds to the non-seasonal MASE, whereas m>1 corresponds to seasonal MASE. If m=None, it will be tentatively inferred from the auto-correlation function (ACF). It will fall back to a value of 1 if this fails.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Raises

ValueError – If the insample series is periodic ( $$X_t = X_{t-m}$$ )

Returns

The Mean Absolute Scaled Error (MASE)

Return type

float

darts.metrics.metrics.mse(actual_series, pred_series, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

Mean Squared Error (MSE).

For two time series $$y^1$$ and $$y^2$$ of length $$T$$, it is computed as

$\frac{1}{T}\sum_{t=1}^T{(y^1_t - y^2_t)^2}.$

If any of the series is stochastic (containing several samples), the median sample value is considered.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Returns

The Mean Squared Error (MSE)

Return type

float

darts.metrics.metrics.multi_ts_support(func)[source]

This decorator further adapts the metrics that took as input two univariate/multivariate TimeSeries instances, adding support for equally-sized sequences of TimeSeries instances. The decorator computes the pairwise metric for TimeSeries with the same indices, and returns a float value that is computed as a function of all the pairwise metrics using a inter_reduction subroutine passed as argument to the metric function.

If a ‘Sequence[TimeSeries]’ is passed as input, this decorator provides also parallelisation of the metric evaluation regarding different TimeSeries (if the n_jobs parameter is not set 1).

darts.metrics.metrics.multivariate_support(func)[source]

This decorator transforms a metric function that takes as input two univariate TimeSeries instances into a function that takes two equally-sized multivariate TimeSeries instances, computes the pairwise univariate metrics for components with the same indices, and returns a float value that is computed as a function of all the univariate metrics using a reduction subroutine passed as argument to the metric function.

darts.metrics.metrics.ope(actual_series, pred_series, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

Overall Percentage Error (OPE).

Given a time series of actual values $$y_t$$ and a time series of predicted values $$\hat{y}_t$$ both of length $$T$$, it is a percentage value computed as

$100 \cdot \left| \frac{\sum_{t=1}^{T}{y_t} - \sum_{t=1}^{T}{\hat{y}_t}}{\sum_{t=1}^{T}{y_t}} \right|.$

If any of the series is stochastic (containing several samples), the median sample value is considered.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Raises

ValueError – If $$\sum_{t=1}^{T}{y_t} = 0$$.

Returns

The Overall Percentage Error (OPE)

Return type

float

darts.metrics.metrics.quantile_loss(actual_series, pred_series, tau=0.5, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

Also known as Pinball Loss, given a time series of actual values $$y$$ of length $$T$$ and a time series of stochastic predictions (containing N samples) $$y'$$ of shape $$T x N$$ quantile loss is a metric that quantifies the accuracy of a specific quantile $$tau$$ from the predicted value distribution.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• tau (float) – The quantile (float [0, 1]) of interest for the loss.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Returns

The quantile loss metric

Return type

float

darts.metrics.metrics.r2_score(actual_series, pred_series, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

Coefficient of Determination $$R^2$$.

See Coefficient of determination wikipedia page for details about the $$R^2$$ score and how it is computed. Please note that this metric is not symmetric, actual_series should correspond to the ground truth series, whereas pred_series should correspond to the predicted series.

If any of the series is stochastic (containing several samples), the median sample value is considered.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Returns

The Coefficient of Determination $$R^2$$

Return type

float

darts.metrics.metrics.rho_risk(actual_series, pred_series, rho=0.5, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

$$\rho$$-risk (rho-risk or quantile risk).

Given a time series of actual values $$y_t$$ of length $$T$$ and a time series of stochastic predictions (containing N samples) $$\hat{y}_t$$ of shape $$T \times N$$, rho-risk is a metric that quantifies the accuracy of a specific quantile $$\rho$$ from the predicted value distribution.

For a univariate stochastic predicted TimeSeries the $$\rho$$-risk is given by:

$\frac{ L_{\rho} \left( Z, \hat{Z}_{\rho} \right) } {Z},$

where $$L_{\rho} \left( Z, \hat{Z}_{\rho} \right)$$ is the $$\rho$$-loss function:

$L_{\rho} \left( Z, \hat{Z}_{\rho} \right) = 2 \left( Z - \hat{Z}_{\rho} \right) \left( \rho I_{\hat{Z}_{\rho} < Z} - \left( 1 - \rho \right) I_{\hat{Z}_{\rho} \geq Z} \right),$

where $$Z = \sum_{t=1}^{T} y_t$$ (1) is the aggregated target value and $$\hat{Z}_{\rho}$$ is the $$\rho$$-quantile of the predicted values. For this, each sample realization $$i \in N$$ is first aggregated over the time span similar to (1) with $$\hat{Z}_{i} = \sum_{t=1}^{T} \hat{y}_{i,t}$$.

$$I_{cond} = 1$$ if cond is True else $$0$$

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• rho (float) – The quantile (float [0, 1]) of interest for the risk evaluation.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Returns

The rho-risk metric

Return type

float

darts.metrics.metrics.rmse(actual_series, pred_series, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

Root Mean Squared Error (RMSE).

For two time series $$y^1$$ and $$y^2$$ of length $$T$$, it is computed as

$\sqrt{\frac{1}{T}\sum_{t=1}^T{(y^1_t - y^2_t)^2}}.$

If any of the series is stochastic (containing several samples), the median sample value is considered.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Returns

The Root Mean Squared Error (RMSE)

Return type

float

darts.metrics.metrics.rmsle(actual_series, pred_series, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

Root Mean Squared Log Error (RMSLE).

For two time series $$y^1$$ and $$y^2$$ of length $$T$$, it is computed as

$\sqrt{\frac{1}{T}\sum_{t=1}^T{\left(\log{(y^1_t + 1)} - \log{(y^2_t + 1)}\right)^2}},$

using the natural logarithm.

If any of the series is stochastic (containing several samples), the median sample value is considered.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Returns

The Root Mean Squared Log Error (RMSLE)

Return type

float

darts.metrics.metrics.smape(actual_series, pred_series, intersect=True, *, reduction=<function mean>, inter_reduction=<function <lambda>>, n_jobs=1, verbose=False)[source]

symmetric Mean Absolute Percentage Error (sMAPE).

Given a time series of actual values $$y_t$$ and a time series of predicted values $$\hat{y}_t$$ both of length $$T$$, it is a percentage value computed as

$200 \cdot \frac{1}{T} \sum_{t=1}^{T}{\frac{\left| y_t - \hat{y}_t \right|}{\left| y_t \right| + \left| \hat{y}_t \right|} }.$
Note that it will raise a ValueError if $$\left| y_t \right| + \left| \hat{y}_t \right| = 0$$

for some $$t$$. Consider using the Mean Absolute Scaled Error (MASE) in these cases.

If any of the series is stochastic (containing several samples), the median sample value is considered.

Parameters
• actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

• pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

• intersect (bool) – For time series that are overlapping in time without having the same time index, setting True will consider the values only over their common time interval (intersection in time).

• reduction (Callable[[ndarray], float]) – Function taking as input a np.ndarray and returning a scalar value. This function is used to aggregate the metrics of different components in case of multivariate TimeSeries instances.

• inter_reduction (Callable[[ndarray], Union[float, ndarray]]) – Function taking as input a np.ndarray and returning either a scalar value or a np.ndarray. This function can be used to aggregate the metrics of different series in case the metric is evaluated on a Sequence[TimeSeries]. Defaults to the identity function, which returns the pairwise metrics for each pair of TimeSeries received in input. Example: inter_reduction=np.mean, will return the average of the pairwise metrics.

• n_jobs (int) – The number of jobs to run in parallel. Parallel jobs are created only when a Sequence[TimeSeries] is passed as input, parallelising operations regarding different TimeSeries. Defaults to 1 (sequential). Setting the parameter to -1 means using all the available processors.

• verbose (bool) – Optionally, whether to print operations progress

Raises

ValueError – If the actual series and the pred series contains some zeros at the same time index.

Returns

The symmetric Mean Absolute Percentage Error (sMAPE)

Return type

float