utils

Functions

_estimate_n_folds(num_points, horizon, ...)

Estimate number of folds.

_max_n_folds_backtest(pipeline, ...)

Estimate max n_folds for backtest method.

_max_n_folds_forecast(pipeline, context_size)

Estimate max n_folds for forecast method.

estimate_max_n_folds(pipeline, method_name, ...)

Estimate number of folds using provided data and pipeline configuration.

remove_params(params, to_remove)

Select forecast arguments from params.

Classes

MethodsWithFolds(value)

Enum for methods that use n_folds argument.

class MethodsWithFolds(value)[source]

Enum for methods that use n_folds argument.

estimate_max_n_folds(pipeline: etna.pipeline.pipeline.Pipeline, method_name: Union[Literal['forecast'], Literal['backtest']], context_size: int, ts: Optional[etna.datasets.tsdataset.TSDataset] = None, **method_kwargs) int[source]

Estimate number of folds using provided data and pipeline configuration.

This function helps to estimate maximum number of folds that can be used when performing forecast with intervals or pipeline backtest. Number of folds estimated using the following formula:

\[max\_n\_folds = \left\lfloor\frac{num\_points - horizon + stride - context\_size}{stride}\right\rfloor,\]

where \(num\_points\) is number of points in the dataset, \(horizon\) is length of forecasting horizon, \(stride\) is number of points between folds, \(context\_size\) is pipeline context size.

Parameters
  • pipeline (etna.pipeline.pipeline.Pipeline) – Pipeline for which to estimate number of folds.

  • method_name (Union[Literal['forecast'], typing.Literal['backtest']]) – Method name for which to estimate number of folds.

  • context_size (int) – Minimum number of points for pipeline to be estimated.

  • ts (Optional[etna.datasets.tsdataset.TSDataset]) – Dataset which will be used for estimation.

  • method_kwargs – Additional arguments for methods that impact number of folds.

Returns

Number of folds.

Return type

int

remove_params(params: Dict[str, Any], to_remove: Set[str]) Dict[str, Any][source]

Select forecast arguments from params.

Parameters
  • params (Dict[str, Any]) –

  • to_remove (Set[str]) –

Return type

Dict[str, Any]