Source code for darts.ad.anomaly_model.forecasting_am
`train_length`.
enable_optimization Whether to use the optimized version of historical_forecasts when supported and available.
+ Default: ``True``. model_fit_kwargs Parameters to be passed on to the forecast model `fit()` method.
@@ -387,6 +388,7 @@
Source code for darts.ad.anomaly_model.forecasting_am
`train_length`.
enable_optimization Whether to use the optimized version of historical_forecasts when supported and available.
+ Default: ``True``. return_model_prediction Whether to return the forecasting model prediction along with the anomaly scores.
@@ -474,6 +476,7 @@
Source code for darts.ad.anomaly_model.forecasting_am
`train_length`.
enable_optimization Whether to use the optimized version of historical_forecasts when supported and available.
+ Default: ``True``. Returns -------
@@ -569,6 +572,7 @@
Source code for darts.ad.anomaly_model.forecasting_am
`train_length`.
enable_optimization Whether to use the optimized version of historical_forecasts when supported and available.
+ Default: ``True``. metric The name of the metric function to use. Must be one of "AUC_ROC" (Area Under the Receiver Operating Characteristic Curve) and "AUC_PR" (Average Precision from scores).
@@ -674,6 +678,7 @@
Source code for darts.ad.anomaly_model.forecasting_am
`train_length`.
enable_optimization Whether to use the optimized version of historical_forecasts when supported and available.
+ Default: ``True``. anomalies The ground truth of the anomalies (1 if it is an anomaly and 0 if not). names_of_scorers
diff --git a/_modules/darts/ad/detectors/detectors.html b/_modules/darts/ad/detectors/detectors.html
index 46cc75d01f..bf21ed59d5 100644
--- a/_modules/darts/ad/detectors/detectors.html
+++ b/_modules/darts/ad/detectors/detectors.html
@@ -34,7 +34,7 @@
-
+
diff --git a/_modules/darts/ad/detectors/iqr_detector.html b/_modules/darts/ad/detectors/iqr_detector.html
new file mode 100644
index 0000000000..9a56fdca72
--- /dev/null
+++ b/_modules/darts/ad/detectors/iqr_detector.html
@@ -0,0 +1,291 @@
+
+
+
+
+
+
+
+ darts.ad.detectors.iqr_detector — darts documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Source code for darts.ad.detectors.iqr_detector
+"""
+Interquartile Range (IQR) Detector
+-----------------
+
+Flags anomalies that are beyond the IQR (between the third and the first quartile)
+of historical data by some factor of it's difference (typically 1.5).
+This is similar to a threshold-based detector, but the thresholds are
+computed as distances from the IQR of historical data when the detector is fitted.
+"""
+
+fromtypingimportSequence,Union
+
+importnumpyasnp
+
+fromdarts.ad.detectors.quantile_detectorimportQuantileDetector
+fromdarts.ad.detectors.threshold_detectorimportThresholdDetector
+fromdarts.loggingimportget_logger,raise_log
+fromdarts.timeseriesimportTimeSeries
+
+logger=get_logger(__name__)
+
+
+
[docs]classIQRDetector(QuantileDetector):
+ def__init__(self,scale:Union[Sequence[float],float]=1.5)->None:
+"""IQR Detector
+
+ Flags values that lie outside of the interquartile range (IQR)
+ by more than a certain factor of IQR's value as anomalies.
+ The factor is passed in the `scale` parameter.
+
+ If a single value is provided for `scale`,
+ this same value will be used across all components of the series.
+
+ If a sequences of values is given for the `scale` parameter,
+ it's length must match the dimensionality of the series passed.
+
+ Parameters
+ ----------
+ scale
+ (Sequence of) scale(s) used to indicate what distance from the IQR constitutes an anomaly.
+ Defaults to `1.5`. Must be non-negative. If a sequence, must match the dimensionality of the series
+ this detector is applied to.
+ """
+
+ # Parent QuantileDetector will compute Q1 and Q3 thresholds
+ super().__init__(low_quantile=0.25,high_quantile=0.75)
+
+ self.scale=np.array(scale)
+ ifself.scale.ndim==0:
+ self.scale=np.expand_dims(self.scale,0)
+
+ ifnotnp.issubdtype(self.scale.dtype,np.number)or(self.scale<0.0).any():
+ raise_log(
+ ValueError("All values in `scale` must be non-negative numbers."),
+ logger=logger,
+ )
+
+ def_fit_core(self,series:Sequence[TimeSeries])->None:
+ super()._fit_core(series)
+
+ iflen(self.scale)>1andlen(self.scale)!=series[0].width:
+ raise_log(
+ ValueError(
+ "The number of components of input must be equal to the number "
+ "of values given for `scale`. Found number of components "
+ f"equal to {series[0].width} and expected {len(self.scale)}."
+ ),
+ logger=logger,
+ )
+
+ low_threshold=np.array(self.detector.low_threshold)
+ high_threshold=np.array(self.detector.high_threshold)
+
+ IQR=high_threshold-low_threshold
+
+ low_threshold-=self.scale*IQR
+ high_threshold+=self.scale*IQR
+
+ self.detector=ThresholdDetector(
+ low_threshold=list(low_threshold),high_threshold=list(high_threshold)
+ )
# filter column down to the period of recordingsrs=srs.replace(0.0,np.nan)
- start_date=min(srs.fillna(method="ffill").dropna().index)
- end_date=max(srs.fillna(method="bfill").dropna().index)
+ start_date=min(srs.ffill().dropna().index)
+ end_date=max(srs.bfill().dropna().index)active_range=(srs.index>=start_date)&(srs.index<=end_date)srs=srs[active_range].fillna(0.0)
@@ -845,8 +845,8 @@
Source code for darts.datasets
srs=series[label]# filter column down to the period of recording
- start_date=min(srs.fillna(method="ffill").dropna().index)
- end_date=max(srs.fillna(method="bfill").dropna().index)
+ start_date=min(srs.ffill().dropna().index)
+ end_date=max(srs.bfill().dropna().index)active_range=(srs.index>=start_date)&(srs.index<=end_date)srs=srs[active_range]
diff --git a/_modules/darts/datasets/dataset_loaders.html b/_modules/darts/datasets/dataset_loaders.html
index 44504864a8..dd13fbb3d4 100644
--- a/_modules/darts/datasets/dataset_loaders.html
+++ b/_modules/darts/datasets/dataset_loaders.html
@@ -34,7 +34,7 @@
-
+
diff --git a/_modules/darts/explainability/explainability_result.html b/_modules/darts/explainability/explainability_result.html
index efa26767c6..1826c8eeb1 100644
--- a/_modules/darts/explainability/explainability_result.html
+++ b/_modules/darts/explainability/explainability_result.html
@@ -34,7 +34,7 @@
-
+
diff --git a/_modules/darts/explainability/shap_explainer.html b/_modules/darts/explainability/shap_explainer.html
index 10bca2742a..8bf75152fa 100644
--- a/_modules/darts/explainability/shap_explainer.html
+++ b/_modules/darts/explainability/shap_explainer.html
@@ -34,7 +34,7 @@
-
+
@@ -833,7 +833,7 @@
Source code for darts.explainability.shap_explainer
importinspectfromfunctoolsimportwrapsfrominspectimportsignature
-fromtypingimportCallable,List,Optional,Sequence,Tuple,Union
+fromtypingimportAny,Callable,List,Optional,Sequence,Tuple,Unionimportnumpyasnp
+importpandasaspdfromdartsimportTimeSeriesfromdarts.dataprocessingimportdtwfromdarts.loggingimportget_logger,raise_log
-fromdarts.utilsimport_build_tqdm_iterator,_parallel_apply,n_steps_betweenfromdarts.utils.ts_utilsimportSeriesType,get_series_seq_type,series2seq
+fromdarts.utils.utilsimport(
+ _build_tqdm_iterator,
+ _parallel_apply,
+ likelihood_component_names,
+ n_steps_between,
+ quantile_names,
+)logger=get_logger(__name__)TIME_AX=0COMP_AX=1
+SMPL_AX=2# Note: for new metrics added to this module to be able to leverage the two decorators, it is required both having# the `actual_series` and `pred_series` parameters, and not having other ``Sequence`` as args (since these decorators
@@ -208,6 +216,51 @@
Source code for darts.metrics.metrics
]
+
[docs]definterval_support(func)->Callable[...,METRIC_OUTPUT_TYPE]:
+"""
+ This decorator adds support for quantile interval metrics with sanity checks, processing, and extraction of
+ quantiles from the intervals.
+ """
+
+ @wraps(func)
+ defwrapper_interval_support(*args,**kwargs):
+ q=kwargs.get("q")
+ ifqisnotNone:
+ raise_log(
+ ValueError(
+ "`q` is not supported for quantile interval metrics; use `q_interval` instead."
+ )
+ )
+ q_interval=kwargs.get("q_interval")
+ ifq_intervalisNone:
+ raise_log(
+ ValueError("Quantile interval metrics require setting `q_interval`.")
+ )
+ ifisinstance(q_interval,tuple):
+ q_interval=[q_interval]
+ q_interval=np.array(q_interval)
+ ifnotq_interval.ndim==2orq_interval.shape[1]!=2:
+ raise_log(
+ ValueError(
+ "`q_interval` must be a tuple (float, float) or a sequence of tuples (float, float)."
+ ),
+ logger=logger,
+ )
+ ifnotnp.all(q_interval[:,1]-q_interval[:,0]>0):
+ raise_log(
+ ValueError(
+ "all intervals in `q_interval` must be tuples of (lower q, upper q) with `lower q > upper q`. "
+ f"Received `q_interval={q_interval}`"
+ ),
+ logger=logger,
+ )
+ kwargs["q_interval"]=q_interval
+ kwargs["q"]=np.sort(np.unique(q_interval))
+ returnfunc(*args,**kwargs)
+
+ returnwrapper_interval_support
+
+
[docs]defmulti_ts_support(func)->Callable[...,METRIC_OUTPUT_TYPE]:""" This decorator further adapts the metrics that took as input two (or three for scaled metrics with `insample`)
@@ -235,12 +288,7 @@
Source code for darts.metrics.metrics
params=signature(func).parametersn_jobs=kwargs.pop("n_jobs",params["n_jobs"].default)
- ifnotisinstance(n_jobs,int):
- raise_log(ValueError("n_jobs must be an integer"),logger=logger)
-
verbose=kwargs.pop("verbose",params["verbose"].default)
- ifnotisinstance(verbose,bool):
- raise_log(ValueError("verbose must be a bool"),logger=logger)# sanity check reduction functions_=_get_reduction(
@@ -306,6 +354,38 @@
Source code for darts.metrics.metrics
num_series_in_args+=int("insample"notinkwargs)kwargs.pop("insample",0)
+ # handle `q` (quantile) parameter for probabilistic (or quantile) forecasts
+ if"q"inparams:
+ # convert `q` to tuple of (quantile values, optional quantile component names)
+ q=kwargs.get("q",params["q"].default)
+ q_comp_names=None
+ ifqisNone:
+ kwargs["q"]=None
+ else:
+ ifisinstance(q,tuple):
+ q,q_comp_names=q
+ ifisinstance(q,float):
+ q=np.array([q])
+ else:
+ q=np.array(q)
+
+ ifnotnp.all(q[1:]-q[:-1]>0.0):
+ raise_log(
+ ValueError(
+ "`q` must be of type `float`, or a sequence of increasing order with unique values only. "
+ f"Received `q={q}`."
+ ),
+ logger=logger,
+ )
+ ifnotnp.all(q>=0.0)&np.all(q<=1.0):
+ raise_log(
+ ValueError(
+ f"All `q` values must be in the range `(>=0,<=1)`. Received `q={q}`."
+ ),
+ logger=logger,
+ )
+ kwargs["q"]=(q,q_comp_names)
+
iterator=_build_tqdm_iterator(iterable=zip(*input_series),verbose=verbose,
@@ -362,20 +442,61 @@
Source code for darts.metrics.metrics
pred_series=args[1]num_series_in_args=2
- ifactual_series.width!=pred_series.width:
- raise_log(
- ValueError(
- f"Mismatch between number of components in `actual_series` "
- f"(n={actual_series.width}) and `pred_series` (n={pred_series.width}."
- ),
- logger=logger,
- )
+ q,q_comp_names=kwargs.get("q"),None
+ ifqisNone:
+ # without quantiles, the number of components must match
+ ifactual_series.n_components!=pred_series.n_components:
+ raise_log(
+ ValueError(
+ f"Mismatch between number of components in `actual_series` "
+ f"(n={actual_series.width}) and `pred_series` (n={pred_series.width})."
+ ),
+ logger=logger,
+ )
+ # compute median for stochastic predictions
+ ifpred_series.is_stochastic:
+ q=np.array([0.5])
+ else:
+ # `q` is required to be a tuple (handled by `multi_ts_support` wrapper)
+ ifnotisinstance(q,tuple)ornotlen(q)==2:
+ raise_log(
+ ValueError(
+ "`q` must be of tuple of `(np.ndarray, Optional[pd.Index])` "
+ "where the (quantile values, optioanl quantile component names). "
+ f"Received `q={q}`."
+ ),
+ logger=logger,
+ )
+ q,q_comp_names=q
+ ifnotpred_series.is_stochastic:
+ # quantile component names are required if the predictions are not stochastic (as for stocahstic
+ # predictions, the quantiles can be retrieved from the sample dimension for each component)
+ ifq_comp_namesisNone:
+ q_comp_names=pd.Index(
+ likelihood_component_names(
+ components=actual_series.components,
+ parameter_names=quantile_names(q=q),
+ )
+ )
+ ifnotq_comp_names.isin(pred_series.components).all():
+ raise_log(
+ ValueError(
+ f"Computing a metric with quantile(s) `q={q}` is only supported for probabilistic "
+ f"`pred_series` (num samples > 1) or `pred_series` containing the predicted "
+ f"quantiles as columns / components. Either pass a probabilistic `pred_series` or "
+ f"a series containing the expected quantile components: {q_comp_names.tolist()} "
+ ),
+ logger=logger,
+ )
+
+ if"q"inparams:
+ kwargs["q"]=(q,q_comp_names)# handle `insample` parameters for scaled metricsinput_series=(actual_series,pred_series)if"insample"inparams:insample=args[2]
- ifactual_series.width!=insample.width:
+ ifactual_series.n_components!=insample.n_components:raise_log(ValueError(f"Mismatch between number of components in `actual_series` "
@@ -387,15 +508,18 @@
Source code for darts.metrics.metrics
num_series_in_args+=1vals=func(*input_series,*args[num_series_in_args:],**kwargs)
- ifnot1<=len(vals.shape)<=2:
+ # bring vals to shape (n_time, n_comp, n_quantile)
+ ifnot2<=len(vals.shape)<=3:raise_log(ValueError(
- "Metric output must have 1 dimension for aggregated metrics (e.g. `mae()`, ...), "
- "or 2 dimension for time dependent metrics (e.g. `ae()`, ...)"
+ "Metric output must have 2 dimensions (n components, n quantiles) "
+ "for aggregated metrics (e.g. `mae()`, ...), "
+ "or 3 dimension (n times, n components, n quantiles) "
+ "for time dependent metrics (e.g. `ae()`, ...)"),logger=logger,)
- eliflen(vals.shape)==1:
+ iflen(vals.shape)==2:vals=np.expand_dims(vals,TIME_AX)time_reduction=_get_reduction(
@@ -406,6 +530,7 @@
def_get_values(
- vals:np.ndarray,stochastic_quantile:Optional[float]=0.5
+ vals:np.ndarray,
+ vals_components:pd.Index,
+ actual_components:pd.Index,
+ q:Optional[Tuple[Sequence[float],Union[Optional[pd.Index]]]]=None,)->np.ndarray:"""
- Returns a deterministic or probabilistic numpy array from the values of a time series.
- For stochastic input values, return either all sample values with (stochastic_quantile=None) or the quantile sample
- value with (stochastic_quantile {>=0,<=1})
+ Returns a deterministic or probabilistic numpy array from the values of a time series of shape
+ (times, components, samples / quantiles).
+ To extract quantile (sample) values from quantile or stachastic `vals`, use `q`.
+
+ Parameters
+ ----------
+ vals
+ A numpy array with the values of a TimeSeries (actual values or predictions).
+ vals_components
+ The components of the `vals` TimeSeries.
+ actual_components
+ The components of the actual TimeSeries.
+ q
+ Optionally, for stochastic or quantile series/values, return deterministic quantile values.
+ If not `None`, must a tuple with (quantile values,
+ `None` if `pred_series` is stochastic else the quantile component names). """
- ifvals.shape[2]==1:# deterministic
- out=vals[:,:,0]
- else:# stochastic
- ifstochastic_quantileisNone:
- out=vals
- else:
- out=np.quantile(vals,stochastic_quantile,axis=2)
- returnout
+ # return values as is (times, components, samples)
+ ifqisNone:
+ returnvals
+
+ q,q_names=q
+ ifvals.shape[SMPL_AX]==1:# deterministic (or quantile components) input
+ ifq_namesisnotNone:
+ # `q_names` are the component names of the predicted quantile parameters
+ # we extract the relevant quantile components with shape (times, components * quantiles)
+ vals=vals[:,vals_components.get_indexer(q_names)]
+ # rearrange into (times, components, quantiles)
+ vals=vals.reshape((len(vals),len(actual_components),-1))
+ returnvals
+
+ # probabilistic input
+ # compute multiple quantiles for all times and components; with shape: (quantiles, times, components)
+ out=np.quantile(vals,q,axis=SMPL_AX)
+ # rearrange into (times, components, quantiles)
+ returnout.transpose((1,2,0))def_get_values_or_raise(series_a:TimeSeries,series_b:TimeSeries,intersect:bool,
- stochastic_quantile:Optional[float]=0.5,
+ q:Optional[Tuple[Sequence[float],Union[Optional[pd.Index]]]]=None,remove_nan_union:bool=False,is_insample:bool=False,)->Tuple[np.ndarray,np.ndarray]:"""Returns the processed numpy values of two time series. Processing can be customized with arguments
- `intersect, stochastic_quantile, remove_nan_union`.
+ `intersect, q, remove_nan_union`. Parameters ----------
@@ -460,9 +616,10 @@
Source code for darts.metrics.metrics
A deterministic or stochastic ``TimeSeries`` instance (the predictions `pred_series`). intersect A boolean for whether to only consider the time intersection between `series_a` and `series_b`
- stochastic_quantile
- Optionally, for stochastic predicted series, return either all sample values with (`stochastic_quantile=None`)
- or any deterministic quantile sample values by setting `stochastic_quantile=quantile` {>=0,<=1}.
+ q
+ Optionally, for predicted stochastic or quantile series, return deterministic quantile values.
+ If not `None`, must a tuple with (quantile values,
+ `None` if `pred_series` is stochastic else the quantile component names). remove_nan_union By setting `remove_non_union` to True, sets all values from `series_a` and `series_b` to `np.nan` at indices where any of the two series contain a NaN value. Only effective when `is_insample=False`.
@@ -474,16 +631,6 @@
Source code for darts.metrics.metrics
ValueError If `is_insample=False` and the two time series do not have at least a partially overlapping time index. """
-
- ifnotseries_a.width==series_b.width:
- raise_log(
- ValueError("The two time series must have the same number of components"),
- logger=logger,
- )
-
- ifnotisinstance(intersect,bool):
- raise_log(ValueError("The intersect parameter must be a bool"),logger=logger)
-
make_copy=Falseifnotis_insample:# get the time intersection and values of the two series (corresponds to `actual_series` and `pred_series`
@@ -494,15 +641,12 @@
Source code for darts.metrics.metrics
vals_a_common=series_a.slice_intersect_values(series_b,copy=make_copy)vals_b_common=series_b.slice_intersect_values(series_a,copy=make_copy)
- ifnotlen(vals_a_common)==len(vals_b_common):
- raise_log(
- ValueError(
- "The two time series must have at least a partially overlapping time index."
- ),
- logger=logger,
- )
-
- vals_b_det=_get_values(vals_b_common,stochastic_quantile=stochastic_quantile)
+ vals_b=_get_values(
+ vals=vals_b_common,
+ vals_components=series_b.components,
+ actual_components=series_a.components,
+ q=q,
+ )else:# for `insample` series we extract only values up until before start of `pred_series`# find how many steps `insample` overlaps into `series_b`
@@ -522,36 +666,67 @@
Source code for darts.metrics.metrics
)end=endorNonevals_a_common=series_a.all_values(copy=make_copy)[:end]
- vals_b_det=None
- vals_a_det=_get_values(vals_a_common,stochastic_quantile=stochastic_quantile)
+ vals_b=None
+ vals_a=_get_values(
+ vals=vals_a_common,
+ vals_components=series_a.components,
+ actual_components=series_a.components,
+ q=([0.5],None),
+ )ifnotremove_nan_unionoris_insample:
- returnvals_a_det,vals_b_det
+ returnvals_a,vals_b
- b_is_deterministic=bool(len(vals_b_det.shape)==2)
- ifb_is_deterministic:
- isnan_mask=np.logical_or(np.isnan(vals_a_det),np.isnan(vals_b_det))
- isnan_mask_pred=isnan_mask
- else:
- isnan_mask=np.logical_or(
- np.isnan(vals_a_det),np.isnan(vals_b_det).any(axis=2)
- )
- isnan_mask_pred=np.repeat(
- np.expand_dims(isnan_mask,axis=-1),vals_b_det.shape[2],axis=2
- )
- returnnp.where(isnan_mask,np.nan,vals_a_det),np.where(
- isnan_mask_pred,np.nan,vals_b_det
+ isnan_mask=np.expand_dims(
+ np.logical_or(np.isnan(vals_a),np.isnan(vals_b)).any(axis=SMPL_AX),axis=-1
+ )
+ isnan_mask_pred=np.repeat(isnan_mask,vals_b.shape[SMPL_AX],axis=SMPL_AX)
+ returnnp.where(isnan_mask,np.nan,vals_a),np.where(
+ isnan_mask_pred,np.nan,vals_b)
+def_get_quantile_intervals(
+ vals:np.ndarray,
+ q:Tuple[Sequence[float],Any],
+ q_interval:np.ndarray=None,
+)->Tuple[np.ndarray,np.ndarray]:
+"""Returns the lower and upper bound values from `vals` for all quantile intervals in `q_interval`.
+
+ Parameters
+ ----------
+ vals
+ A numpy array with predicted quantile values of shape (n times, n components, n quantiles).
+ q
+ A tuple with (quantile values, any).
+ q_interval
+ A numpy array with the lower and upper quantile interval bound of shape (n intervals, 2).
+ """
+ q,_=q
+ # find index of every `q_interval` value in `q`; we have guarantees from support wrappers:
+ # - `q` has increasing order
+ # - `vals` has same order as `q` in dim 3 (quantile dim)
+ # - `q_interval` holds (lower q, upper q) in that order
+ q_idx=np.searchsorted(q,q_interval.flatten()).reshape(q_interval.shape)
+ returnvals[:,:,q_idx[:,0]],vals[:,:,q_idx[:,1]]
+
+
def_get_wrapped_metric(
- func:Callable[...,METRIC_OUTPUT_TYPE],
+ func:Callable[...,METRIC_OUTPUT_TYPE],n_wrappers:int=2)->Callable[...,METRIC_OUTPUT_TYPE]:"""Returns the inner metric function `func` which bypasses the decorators `multi_ts_support` and `multivariate_support`. It significantly decreases process time compared to calling `func` directly. Only use this to compute a pre-defined metric within the scope of another metric. """
- returnfunc.__wrapped__.__wrapped__
+ ifnot2<=n_wrappers<=3:
+ raise_log(
+ NotImplementedError("Only 2-3 wrappers are currently supported"),
+ logger=logger,
+ )
+ ifn_wrappers==2:
+ returnfunc.__wrapped__.__wrapped__
+ else:
+ returnfunc.__wrapped__.__wrapped__.__wrapped__def_get_reduction(
@@ -646,6 +821,7 @@
.. math:: y_t - \\hat{y}_t
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -671,6 +848,8 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. time_reduction Optionally, a function to aggregate the metrics over the time axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(c,)`. The function takes as input a ``np.ndarray`` and a
@@ -682,10 +861,11 @@
Source code for darts.metrics.metrics
parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -717,7 +897,11 @@
.. math:: \\frac{1}{T}\\sum_{t=1}^T{(y_t - \\hat{y}_t)}
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -753,16 +939,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -793,6 +982,7 @@
.. math:: |y_t - \\hat{y}_t|
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -830,6 +1022,8 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. time_reduction Optionally, a function to aggregate the metrics over the time axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(c,)`. The function takes as input a ``np.ndarray`` and a
@@ -841,15 +1035,11 @@
Source code for darts.metrics.metrics
parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
- series_reduction
- Optionally, a function taking as input a ``np.ndarray`` and returning either a scalar value or a ``np.ndarray``.
- This function is used to aggregate the metrics in case the metric is evaluated on multiple series
- (e.g., on a ``Sequence[TimeSeries]``). By default, returns the metric for each series.
- Example: ``series_reduction=np.nanmean``, will return the average over all series metrics.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -881,7 +1071,11 @@
.. math:: \\frac{1}{T}\\sum_{t=1}^T{|y_t - \\hat{y}_t|}
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -917,21 +1113,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
- series_reduction
- Optionally, a function taking as input a ``np.ndarray`` and returning either a scalar value or a ``np.ndarray``.
- This function is used to aggregate the metrics in case the metric is evaluated on multiple series
- (e.g., on a ``Sequence[TimeSeries]``). By default, returns the metric for each series.
- Example: ``series_reduction=np.nanmean``, will return the average over all series metrics.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -962,6 +1156,7 @@
.. math:: E_m = MAE(y_{m:t_p}, y_{0:t_p - m}).
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -1016,6 +1213,8 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. time_reduction Optionally, a function to aggregate the metrics over the time axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(c,)`. The function takes as input a ``np.ndarray`` and a
@@ -1027,10 +1226,11 @@
Source code for darts.metrics.metrics
parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -1075,6 +1275,7 @@
.. math:: E_m = MAE(y_{m:t_p}, y_{0:t_p - m}).
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -1127,16 +1330,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -1179,6 +1385,7 @@
.. math:: (y_t - \\hat{y}_t)^2.
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -1216,6 +1425,8 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. time_reduction Optionally, a function to aggregate the metrics over the time axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(c,)`. The function takes as input a ``np.ndarray`` and a
@@ -1227,10 +1438,11 @@
Source code for darts.metrics.metrics
parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -1262,7 +1474,11 @@
.. math:: \\frac{1}{T}\\sum_{t=1}^T{(y_t - \\hat{y}_t)^2}.
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -1298,16 +1516,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -1338,6 +1559,7 @@
.. math:: E_m = MSE(y_{m:t_p}, y_{0:t_p - m}).
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -1392,6 +1616,8 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. time_reduction Optionally, a function to aggregate the metrics over the time axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(c,)`. The function takes as input a ``np.ndarray`` and a
@@ -1403,10 +1629,11 @@
Source code for darts.metrics.metrics
parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -1451,6 +1678,7 @@
.. math:: E_m = MSE(y_{m:t_p}, y_{0:t_p - m}).
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -1503,16 +1733,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -1555,6 +1788,7 @@
.. math:: \\sqrt{\\frac{1}{T}\\sum_{t=1}^T{(y_t - \\hat{y}_t)^2}}
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -1591,16 +1827,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -1631,6 +1870,7 @@
.. math:: E_m = RMSE(y_{m:t_p}, y_{0:t_p - m}).
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -1683,16 +1925,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -1733,6 +1978,7 @@
using the natural logarithm.
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -1771,6 +2019,8 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. time_reduction Optionally, a function to aggregate the metrics over the time axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(c,)`. The function takes as input a ``np.ndarray`` and a
@@ -1782,10 +2032,11 @@
Source code for darts.metrics.metrics
parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -1817,7 +2068,11 @@
using the natural logarithm.
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -1856,16 +2113,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -1897,6 +2157,7 @@
Note that it will raise a `ValueError` if :math:`y_t = 0` for some :math:`t`. Consider using the Absolute Scaled Error (:func:`~darts.metrics.metrics.ase`) in these cases.
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -1938,6 +2201,8 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. time_reduction Optionally, a function to aggregate the metrics over the time axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(c,)`. The function takes as input a ``np.ndarray`` and a
@@ -1949,10 +2214,11 @@
Source code for darts.metrics.metrics
parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -1989,7 +2255,11 @@
Note that it will raise a `ValueError` if :math:`y_t = 0` for some :math:`t`. Consider using the Mean Absolute Scaled Error (:func:`~darts.metrics.metrics.mase`) in these cases.
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -2035,16 +2307,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -2081,6 +2356,7 @@
Note that it will raise a `ValueError` if :math:`\\left| y_t \\right| + \\left| \\hat{y}_t \\right| = 0` for some :math:`t`. Consider using the Absolute Scaled Error (:func:`~darts.metrics.metrics.ase`) in these cases.
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -2122,6 +2400,8 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. time_reduction Optionally, a function to aggregate the metrics over the time axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(c,)`. The function takes as input a ``np.ndarray`` and a
@@ -2133,10 +2413,11 @@
Source code for darts.metrics.metrics
parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -2173,7 +2454,11 @@
for some :math:`t`. Consider using the Mean Absolute Scaled Error (:func:`~darts.metrics.metrics.mase`) in these cases.
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -2222,16 +2509,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -2268,6 +2558,7 @@
.. math:: 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), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -2305,16 +2598,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -2347,7 +2643,11 @@
.. math:: 100 \\cdot \\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), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -2395,6 +2697,8 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. time_reduction Optionally, a function to aggregate the metrics over the time axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(c,)`. The function takes as input a ``np.ndarray`` and a
@@ -2406,10 +2710,11 @@
Source code for darts.metrics.metrics
parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -2446,7 +2751,11 @@
.. math:: 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), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -2493,16 +2804,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -2536,6 +2850,7 @@
This metric is not symmetric.
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -2576,16 +2893,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -2616,7 +2936,11 @@
where :math:`RMSE` is the Root Mean Squared Error (:func:`~darts.metrics.metrics.rmse`), and :math:`\\bar{y}` is the average of :math:`y` over all time steps.
- If any of the series is stochastic (containing several samples), :math:`\\hat{y}_t` is the median over all samples
- for time step :math:`t`.
+ If :math:`\\hat{y}_t` are stochastic (contains several samples) or quantile predictions, use parameter `q` to
+ specify on which quantile(s) to compute the metric on. By default, it uses the median 0.5 quantile
+ (over all samples, or, if given, the quantile prediction itself). Parameters ----------
@@ -2658,16 +2984,19 @@
Source code for darts.metrics.metrics
intersect 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).
+ q
+ Optionally, the quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -2695,7 +3024,11 @@
Source code for darts.metrics.metrics
"""y_true,y_pred=_get_values_or_raise(
- actual_series,pred_series,intersect,remove_nan_union=True
+ actual_series,
+ pred_series,
+ intersect,
+ remove_nan_union=True,
+ q=q,)# not calling rmse as y_true and y_pred are np.ndarrayreturn(
@@ -2747,10 +3080,11 @@
Source code for darts.metrics.metrics
parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -2790,9 +3124,9 @@
The (sequence of) actual series. pred_series The (sequence of) predicted series.
- q
- The quantile (float [0, 1]) of interest for the risk evaluation. intersect 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).
+ q
+ The quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -2873,18 +3208,19 @@
Source code for darts.metrics.metrics
actual_series,pred_series,intersect,
- stochastic_quantile=None,
+ q=None,remove_nan_union=True,)z_true=np.nansum(z_true,axis=TIME_AX)z_hat=np.nansum(z_hat,axis=TIME_AX)# aggregate all individual sample realizations
+ # quantile loss
+ q,_=qz_hat_rho=np.quantile(z_hat,q=q,axis=1
- )# get the quantile from aggregated samples
+ ).T# get the quantile from aggregated samples
- # quantile losserrors=z_true-z_hat_rholosses=2*np.maximum((q-1)*errors,q*errors)returnlosses/z_true
"""Quantile Loss (QL). Also known as Pinball Loss. QL is a metric that quantifies the accuracy of a specific quantile :math:`q` from the
- predicted value distribution of a stochastic/probabilistic `pred_series` containing N samples.
+ predicted deterministic quantiles or value distribution of a stochastic/probabilistic `pred_series` containing N
+ samples. QL computes the quantile of all sample values and the loss per time step.
@@ -2916,7 +3253,7 @@
Source code for darts.metrics.metrics
.. math:: 2 \\max((q - 1) (y_t - \\hat{y}_{t,q}), q (y_t - \\hat{y}_{t,q})),
- where :math:`\\hat{y}_{t,q}` is the quantile :math:`q` of all predicted sample values at time :math:`t`.
+ where :math:`\\hat{y}_{t,q}` is quantile value :math:`q` (of all predicted quantiles or samples) at time :math:`t`. The factor `2` makes the loss more interpretable, as for `q=0.5` the loss is identical to the Absolute Error (:func:`~darts.metrics.metrics.ae`).
@@ -2926,11 +3263,11 @@
Source code for darts.metrics.metrics
The (sequence of) actual series. pred_series The (sequence of) predicted series.
- q
- The quantile (float [0, 1]) of interest for the loss. intersect 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).
+ q
+ The quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a
@@ -2942,10 +3279,11 @@
Source code for darts.metrics.metrics
parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the time axis. If `None`, will return a metric per time step. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -2975,22 +3313,14 @@
Source code for darts.metrics.metrics
List[np.ndarray] Same as for type `np.ndarray` but for a sequence of series. """
- ifnotpred_series.is_stochastic:
- raise_log(
- ValueError(
- "quantile/pinball loss (ql) should only be computed for "
- "stochastic predicted TimeSeries."
- ),
- logger=logger,
- )
-
y_true,y_pred=_get_values_or_raise(actual_series,pred_series,intersect,
- stochastic_quantile=q,
+ q=q,remove_nan_union=True,)
+ q,_=qerrors=y_true-y_predlosses=2.0*np.maximum((q-1)*errors,q*errors)returnlosses
"""Mean Quantile Loss (MQL). Also known as Pinball Loss. QL is a metric that quantifies the accuracy of a specific quantile :math:`q` from the
- predicted value distribution of a stochastic/probabilistic `pred_series` containing N samples.
+ predicted deterministic quantiles or value distribution of a stochastic/probabilistic `pred_series` containing N
+ samples. MQL first computes the quantile of all sample values and the loss per time step, and then takes the mean over the time axis.
@@ -3022,7 +3353,7 @@
Source code for darts.metrics.metrics
.. math:: 2 \\frac{1}{T}\\sum_{t=1}^T{\\max((q - 1) (y_t - \\hat{y}_{t,q}), q (y_t - \\hat{y}_{t,q}))},
- where :math:`\\hat{y}_{t,q}` is the quantile :math:`q` of all predicted sample values at time :math:`t`.
+ where :math:`\\hat{y}_{t,q}` is quantile value :math:`q` (of all predicted quantiles or samples) at time :math:`t`. The factor `2` makes the loss more interpretable, as for `q=0.5` the loss is identical to the Mean Absolute Error (:func:`~darts.metrics.metrics.mae`).
@@ -3032,21 +3363,22 @@
Source code for darts.metrics.metrics
The (sequence of) actual series. pred_series The (sequence of) predicted series.
- q
- The quantile (float [0, 1]) of interest for the loss. intersect 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).
+ q
+ The quantile (float [0, 1]) or list of quantiles of interest to compute the metric on. component_reduction Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray` of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the component axis. If `None`, will return a metric per component. series_reduction
- Optionally, a function to aggregate the metrics over the series axis. It must reduce a `np.ndarray`
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray` of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
- series axis. If `None`, will return a metric per series.
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component. n_jobs 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`
@@ -3081,6 +3413,195 @@
Source code for darts.metrics.metrics
),axis=TIME_AX,)
+
+
+
[docs]@interval_support
+@multi_ts_support
+@multivariate_support
+defiw(
+ actual_series:Union[TimeSeries,Sequence[TimeSeries]],
+ pred_series:Union[TimeSeries,Sequence[TimeSeries]],
+ intersect:bool=True,
+ *,
+ q_interval:Union[Tuple[float,float],Sequence[Tuple[float,float]]]=None,
+ q:Optional[Union[float,List[float],Tuple[np.ndarray,pd.Index]]]=None,
+ time_reduction:Optional[Callable[...,np.ndarray]]=None,
+ component_reduction:Optional[Callable[[np.ndarray],float]]=np.nanmean,
+ series_reduction:Optional[Callable[[np.ndarray],Union[float,np.ndarray]]]=None,
+ n_jobs:int=1,
+ verbose:bool=False,
+)->METRIC_OUTPUT_TYPE:
+"""Interval Width (IL).
+
+ IL gives the width of predicted quantile intervals.
+
+ For the true series :math:`y` and predicted stochastic or quantile series :math:`\\hat{y}` of length :math:`T`,
+ it is computed per component/column, quantile interval, and time step
+ :math:`t` as:
+
+ .. math:: \\hat{y}_{t,qh} - \\hat{y}_{t,ql}
+
+ where :math:`\\hat{y}_{t,qh}` are the upper bound quantile values (of all predicted quantiles or samples) at time
+ :math:`t`, and :math:`\\hat{y}_{t,ql}` are the lower bound quantile values.
+
+ Parameters
+ ----------
+ actual_series
+ The (sequence of) actual series.
+ pred_series
+ The (sequence of) predicted series.
+ intersect
+ 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).
+ q_interval
+ The quantile interval(s) to compute the metric on. Must be a tuple (single interval) or sequence tuples
+ (multiple intervals) with elements (low quantile, high quantile).
+ q
+ Quantiles `q` not supported by this metric; use `q_interval` instead.
+ component_reduction
+ Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray`
+ of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a
+ parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the
+ component axis. If `None`, will return a metric per component.
+ time_reduction
+ Optionally, a function to aggregate the metrics over the time axis. It must reduce a `np.ndarray`
+ of shape `(t, c)` to a `np.ndarray` of shape `(c,)`. The function takes as input a ``np.ndarray`` and a
+ parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
+ time axis. If `None`, will return a metric per time step.
+ series_reduction
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray`
+ of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a
+ parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component.
+ n_jobs
+ 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
+ Optionally, whether to print operations progress
+
+ Returns
+ -------
+ float
+ A single metric score for:
+
+ - single univariate series.
+ - single multivariate series with `component_reduction`.
+ - a sequence (list) of uni/multivariate series with `series_reduction`, `component_reduction` and
+ `time_reduction`.
+ np.ndarray
+ A numpy array of metric scores. The array has shape (n time steps, n components) without time
+ and component reductions. For:
+
+ - single multivariate series and at least `component_reduction=None`.
+ - single uni/multivariate series and at least `time_reduction=None`.
+ - a sequence of uni/multivariate series including `series_reduction` and at least one of
+ `component_reduction=None` or `time_reduction=None`.
+ List[float]
+ Same as for type `float` but for a sequence of series.
+ List[np.ndarray]
+ Same as for type `np.ndarray` but for a sequence of series.
+ """
+ y_true,y_pred=_get_values_or_raise(
+ actual_series,
+ pred_series,
+ intersect,
+ remove_nan_union=True,
+ q=q,
+ )
+ y_pred_lo,y_pred_hi=_get_quantile_intervals(y_pred,q=q,q_interval=q_interval)
+ returny_pred_hi-y_pred_lo
+
+
+
[docs]@interval_support
+@multi_ts_support
+@multivariate_support
+defmiw(
+ actual_series:Union[TimeSeries,Sequence[TimeSeries]],
+ pred_series:Union[TimeSeries,Sequence[TimeSeries]],
+ intersect:bool=True,
+ *,
+ q_interval:Union[Tuple[float,float],Sequence[Tuple[float,float]]]=None,
+ q:Optional[Union[float,List[float],Tuple[np.ndarray,pd.Index]]]=None,
+ component_reduction:Optional[Callable[[np.ndarray],float]]=np.nanmean,
+ series_reduction:Optional[Callable[[np.ndarray],Union[float,np.ndarray]]]=None,
+ n_jobs:int=1,
+ verbose:bool=False,
+)->METRIC_OUTPUT_TYPE:
+"""Mean Interval Width (IL).
+
+ IL gives the width of predicted quantile intervals aggregated over time.
+
+ For the true series :math:`y` and predicted stochastic or quantile series :math:`\\hat{y}` of length :math:`T`,
+ it is computed per component/column, quantile interval, and time step
+ :math:`t` as:
+
+ .. math:: \\frac{1}{T}\\sum_{t=1}^T{\\hat{y}_{t,qh} - \\hat{y}_{t,ql}}
+
+ where :math:`\\hat{y}_{t,qh}` are the upper bound quantile values (of all predicted quantiles or samples) at time
+ :math:`t`, and :math:`\\hat{y}_{t,ql}` are the lower bound quantile values.
+
+ Parameters
+ ----------
+ actual_series
+ The (sequence of) actual series.
+ pred_series
+ The (sequence of) predicted series.
+ intersect
+ 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).
+ q_interval
+ The quantile interval(s) to compute the metric on. Must be a tuple (single interval) or sequence tuples
+ (multiple intervals) with elements (low quantile, high quantile).
+ q
+ Quantiles `q` not supported by this metric; use `q_interval` instead.
+ component_reduction
+ Optionally, a function to aggregate the metrics over the component/column axis. It must reduce a `np.ndarray`
+ of shape `(t, c)` to a `np.ndarray` of shape `(t,)`. The function takes as input a ``np.ndarray`` and a
+ parameter named `axis`, and returns the reduced array. The `axis` receives value `1` corresponding to the
+ component axis. If `None`, will return a metric per component.
+ series_reduction
+ Optionally, a function to aggregate the metrics over multiple series. It must reduce a `np.ndarray`
+ of shape `(s, t, c)` to a `np.ndarray` of shape `(t, c)` The function takes as input a ``np.ndarray`` and a
+ parameter named `axis`, and returns the reduced array. The `axis` receives value `0` corresponding to the
+ series axis. For example with `np.nanmean`, will return the average over all series metrics. If `None`, will
+ return a metric per component.
+ n_jobs
+ 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
+ Optionally, whether to print operations progress
+
+ Returns
+ -------
+ float
+ A single metric score for:
+
+ - single univariate series.
+ - single multivariate series with `component_reduction`.
+ - sequence (list) of uni/multivariate series with `series_reduction` and `component_reduction`.
+ np.ndarray
+ A numpy array of metric scores. The array has shape (n components,) without component reduction. For:
+
+ - single multivariate series and at least `component_reduction=None`.
+ - sequence of uni/multivariate series including `series_reduction` and `component_reduction=None`.
+ List[float]
+ Same as for type `float` but for a sequence of series.
+ List[np.ndarray]
+ Same as for type `np.ndarray` but for a sequence of series.
+ """
+ returnnp.nanmean(
+ _get_wrapped_metric(iw,n_wrappers=3)(
+ actual_series,
+ pred_series,
+ intersect,
+ q=q,
+ q_interval=q_interval,
+ ),
+ axis=TIME_AX,
+ )
Source code for darts.models.forecasting.block_rnn_model
nr_params:int,num_layers_out_fc:Optional[List]=None,dropout:float=0.0,
+ activation:str="ReLU",**kwargs,):"""This class allows to create custom block RNN modules that can later be used with Darts'
@@ -238,6 +239,8 @@
Source code for darts.models.forecasting.block_rnn_model
This network connects the last hidden layer of the PyTorch RNN module to the output.
dropout The fraction of neurons that are dropped in all-but-last RNN layers.
+ activation
+ The name of the activation function to be applied between the layers of the fully connected network. **kwargs all parameters required for :class:`darts.models.forecasting.pl_forecasting_module.PLForecastingModule` base class.
@@ -252,6 +255,7 @@
Source code for darts.models.forecasting.block_rnn_model
Source code for darts.models.forecasting.block_rnn_model
def __init__(self,name:str,
+ activation:Optional[str]=None,**kwargs,):"""PyTorch module implementing a block RNN to be used in `BlockRNNModel`.
@@ -291,6 +296,7 @@
Source code for darts.models.forecasting.block_rnn_model
This module uses an RNN to encode the input sequence, and subsequently uses a fully connected
network as the decoder which takes as input the last hidden state of the encoder RNN.
+ Optionally, a non-linear activation function can be applied between the layers of the fully connected network. The final output of the decoder is a sequence of length `output_chunk_length`. In this sense, the `_BlockRNNModule` produces 'blocks' of forecasts at a time (which is different from `_RNNModule` used by the `RNNModel`).
@@ -299,6 +305,9 @@
Source code for darts.models.forecasting.block_rnn_model
----------
name The name of the specific PyTorch RNN module ("RNN", "GRU" or "LSTM").
+ activation
+ The name of the activation function to be applied between the layers of the fully connected network.
+ Options include "ReLU", "Sigmoid", "Tanh", or None for no activation. Default: None. **kwargs all parameters required for the :class:`darts.models.forecasting.CustomBlockRNNModule` base class.
@@ -330,10 +339,15 @@
Source code for darts.models.forecasting.block_rnn_model
# to the output of desired length
last=self.hidden_dimfeats=[]
- forfeatureinself.num_layers_out_fc+[
- self.out_len*self.target_size*self.nr_params
- ]:
+ forindex,featureinenumerate(
+ self.num_layers_out_fc+[self.out_len*self.target_size*self.nr_params]
+ ):feats.append(nn.Linear(last,feature))
+
+ # Add activation only between layers, but not on the final layer
+ ifactivationandindex<len(self.num_layers_out_fc):
+ activation_function=getattr(nn,activation)()
+ feats.append(activation_function)last=featureself.fc=nn.Sequential(*feats)
@@ -370,6 +384,7 @@
Source code for darts.models.forecasting.block_rnn_model
Source code for darts.models.forecasting.block_rnn_model
Sizes of hidden layers connecting the last hidden layer of the RNN module to the output, if any.
dropout Fraction of neurons afected by Dropout.
+ activation
+ The name of a torch.nn activation function to be applied between the layers of the fully connected network.
+ Default: "ReLU". **kwargs Optional arguments to initialize the pytorch_lightning.Module, pytorch_lightning.Trainer, and Darts' :class:`TorchForecastingModel`.
@@ -610,6 +628,7 @@
Source code for darts.models.forecasting.block_rnn_model
Source code for darts.models.forecasting.catboost_model
Control the randomness in the fitting procedure and for sampling.
Default: ``None``. multi_models
- If True, a separate model will be trained for each future lag to predict. If False, a single model is
- trained to predict at step 'output_chunk_length' in the future. Default: True.
+ If True, a separate model will be trained for each future lag to predict. If False, a single model
+ is trained to predict all the steps in 'output_chunk_length' (features lags are shifted back by
+ `output_chunk_length - n` for each step `n`). Default: True. use_static_covariates Whether the model should use static covariate information in case the input `series` passed to ``fit()`` contain static covariates. If ``True``, and static covariates are available at fitting time, will enforce
@@ -340,7 +341,7 @@
Source code for darts.models.forecasting.catboost_model
[docs]classCroston(LocalForecastingModel):def__init__(self,version:str="classic",alpha_d:float=None,alpha_p:float=None,
- add_encoders:Optional[dict]=None,):"""An implementation of the `Croston method <https://otexts.com/fpp3/counts.html>`_ for intermittent
@@ -221,30 +218,6 @@
Source code for darts.models.forecasting.croston
For the "tsb" version, the alpha smoothing parameter to apply on demand. alpha_p For the "tsb" version, the alpha smoothing parameter to apply on probability.
- add_encoders
- A large number of future covariates can be automatically generated with `add_encoders`.
- This can be done by adding multiple pre-defined index encoders and/or custom user-made functions that
- will be used as index encoders. Additionally, a transformer such as Darts' :class:`Scaler` can be added to
- transform the generated covariates. This happens all under one hood and only needs to be specified at
- model creation.
- Read :meth:`SequentialEncoder <darts.dataprocessing.encoders.SequentialEncoder>` to find out more about
- ``add_encoders``. Default: ``None``. An example showing some of ``add_encoders`` features:
-
- .. highlight:: python
- .. code-block:: python
-
- def encode_year(idx):
- return (idx.year - 1950) / 50
-
- add_encoders={
- 'cyclic': {'future': ['month']},
- 'datetime_attribute': {'future': ['hour', 'dayofweek']},
- 'position': {'future': ['relative']},
- 'custom': {'future': [encode_year]},
- 'transformer': Scaler(),
- 'tz': 'CET'
- }
- .. References ----------
@@ -271,7 +244,7 @@
Source code for darts.models.forecasting.croston
[461.7666], [461.7666]]) """
- super().__init__(add_encoders=add_encoders)
+ super().__init__(add_encoders=None)raise_if_not(version.lower()in["classic","optimized","sba","tsb"],'The provided "version" parameter must be set to "classic", "optimized", "sba" or "tsb".',
@@ -298,39 +271,32 @@
[docs]deffit(self,series:TimeSeries):
+ super().fit(series)self._assert_univariate(series)series=self.training_seriesself.model.fit(y=series.values(copy=False).flatten(),
- X=(
- future_covariates.values(copy=False).flatten()
- iffuture_covariatesisnotNone
- elseNone
- ),
+ # X can be used to passe future covariates only when conformal prediction is used
+ X=None,)
- returnself
+ returnself
- def_predict(
+
[docs]defpredict(self,n:int,
- future_covariates:Optional[TimeSeries]=None,num_samples:int=1,verbose:bool=False,):
- super()._predict(n,future_covariates,num_samples)
+ super().predict(n,num_samples)values=self.model.predict(h=n,
- X=(
- future_covariates.values(copy=False).flatten()
- iffuture_covariatesisnotNone
- elseNone
- ),
+ # X can be used to passe future covariates only when conformal prediction is used
+ X=None,)["mean"]
- returnself._build_forecast_series(values)
+ returnself._build_forecast_series(values)
Source code for darts.models.forecasting.ensemble_model
Ensemble Model Base Class
"""
+importosfromabcimportabstractmethod
-fromtypingimportList,Optional,Sequence,Tuple,Union
+fromtypingimportBinaryIO,List,Optional,Sequence,Tuple,Unionfromdarts.loggingimportget_logger,raise_if,raise_if_not,raise_logfromdarts.models.forecasting.forecasting_modelimport(
@@ -186,9 +187,15 @@
Source code for darts.models.forecasting.ensemble_model
[docs]defsave(
+ self,path:Optional[Union[str,os.PathLike,BinaryIO]]=None,**pkl_kwargs
+ )->None:
+"""
+ Saves the ensemble model under a given path or file handle.
+
+ Additionally, two files are stored for each `TorchForecastingModel` under the forecasting models.
+
+ Example for saving and loading a :class:`RegressionEnsembleModel`:
+
+ .. highlight:: python
+ .. code-block:: python
+
+ from darts.models import RegressionEnsembleModel, LinearRegressionModel, TiDEModel
+
+ model = RegressionEnsembleModel(
+ forecasting_models = [
+ LinearRegressionModel(lags=4),
+ TiDEModel(input_chunk_length=4, output_chunk_length=4),
+ ],
+ regression_train_n_points=10,
+ )
+
+ model.save("my_ensemble_model.pkl")
+ model_loaded = RegressionEnsembleModel.load("my_ensemble_model.pkl")
+ ..
+
+ Parameters
+ ----------
+ path
+ Path or file handle under which to save the ensemble model at its current state. If no path is specified,
+ the ensemble model is automatically saved under ``"{RegressionEnsembleModel}_{YYYY-mm-dd_HH_MM_SS}.pkl"``.
+ If the i-th model of `forecasting_models` is a TorchForecastingModel, two files (model object and
+ checkpoint) are saved under ``"{path}.{ithModelClass}_{i}.pt"`` and ``"{path}.{ithModelClass}_{i}.ckpt"``.
+ pkl_kwargs
+ Keyword arguments passed to `pickle.dump()`
+ """
+
+ ifpathisNone:
+ # default path
+ path=self._default_save_path()+".pkl"
+
+ super().save(path,**pkl_kwargs)
+
+ fori,minenumerate(self.forecasting_models):
+ ifTORCH_AVAILABLEandissubclass(type(m),TorchForecastingModel):
+ path_tfm=f"{path}.{type(m).__name__}_{i}.pt"
+ m.save(path=path_tfm)
+
+
[docs]@staticmethod
+ defload(path:Union[str,os.PathLike,BinaryIO])->"EnsembleModel":
+"""
+ Loads the ensemble model from a given path or file handle.
+
+ Parameters
+ ----------
+ path
+ Path or file handle from which to load the ensemble model.
+ """
+
+ model:EnsembleModel=GlobalForecastingModel.load(path)
+
+ fori,minenumerate(model.forecasting_models):
+ ifTORCH_AVAILABLEandissubclass(type(m),TorchForecastingModel):
+ path_tfm=f"{path}.{type(m).__name__}_{i}.pt"
+ model.forecasting_models[i]=TorchForecastingModel.load(path_tfm)
+ returnmodel
Source code for darts.models.forecasting.forecasting_model
Default: ``False``
enable_optimization Whether to use the optimized version of historical_forecasts when supported and available.
+ Default: ``True``. fit_kwargs Additional arguments passed to the model `fit()` method. predict_kwargs
@@ -1368,6 +1374,8 @@
Source code for darts.models.forecasting.forecasting_model
Source code for darts.models.forecasting.forecasting_model
Whether to print progress.
show_warnings Whether to show warnings related to parameters `start`, and `train_length`.
+ predict_likelihood_parameters
+ If set to `True`, the model predict the parameters of its Likelihood parameters instead of the target. Only
+ supported for probabilistic models with `likelihood="quantile"`, `num_samples = 1` and
+ `n<=output_chunk_length`. Default: ``False``.
+ enable_optimization
+ Whether to use the optimized version of historical_forecasts when supported and available.
+ Default: ``True``. metric_kwargs Additional arguments passed to `metric()`, such as `'n_jobs'` for parallelization, `'component_reduction'` for reducing the component wise metrics, seasonality `'m'` for scaled metrics, etc. Will pass arguments to
@@ -1518,9 +1533,9 @@
Source code for darts.models.forecasting.forecasting_model
An numpy array of backtest scores. For single series and one of:
- a single `metric` function, `historical_forecasts` generated with `last_points_only=False`
- and backtest `reduction=None`. The output has shape (n forecasts,).
+ and backtest `reduction=None`. The output has shape (n forecasts, *). - multiple `metric` functions and `historical_forecasts` generated with `last_points_only=False`.
- The output has shape (n metrics,) when using a backtest `reduction`, and (n metrics, n forecasts)
+ The output has shape (*, n metrics) when using a backtest `reduction`, and (n forecasts, *, n metrics) when `reduction=None` - multiple uni/multivariate series including `series_reduction` and at least one of `component_reduction=None` or `time_reduction=None` for "per time step metrics"
@@ -1566,6 +1581,8 @@
Source code for darts.models.forecasting.forecasting_model
Source code for darts.models.forecasting.forecasting_model
Whether to print progress.
show_warnings Whether to show warnings related to parameters `start`, and `train_length`.
+ predict_likelihood_parameters
+ If set to `True`, the model predict the parameters of its Likelihood parameters instead of the target. Only
+ supported for probabilistic models with `likelihood="quantile"`, `num_samples = 1` and
+ `n<=output_chunk_length`. Default: ``False``.
+ enable_optimization
+ Whether to use the optimized version of historical_forecasts when supported and available.
+ Default: ``True``. metric_kwargs Additional arguments passed to `metric()`, such as `'n_jobs'` for parallelization, `'m'` for scaled metrics, etc. Will pass arguments only if they are present in the corresponding metric signature. Ignores
@@ -2179,6 +2207,8 @@
Source code for darts.models.forecasting.forecasting_model