Skip to content

DartsRegressionModel

DartsRegressionModel

class DartsRegressionModel(lags: int | list[int] | dict[str, int | list[int]] | None = None, lags_past_covariates: int | list[int] | dict[str, int | list[int]] | None = None, lags_future_covariates: tuple[int, int] | list[int] | dict[str, tuple[int, int] | list[int]] | None = None, output_chunk_length: int | None = 1, output_chunk_shift: int | None = 0, add_encoders: dict | None = None, model=None, multi_models: bool | None = True, use_static_covariates: bool | None = True, past_covariates: list[str] | None = None, num_samples: int | None = 1000)[source]

Darts Regression Model Estimator.

Parameters:
lagsOne of int, list, dict, default=None

Lagged target values used to predict the next time step. If an integer is given the last lags past lags are used (from -1 backward). Otherwise a list of integers with lags is required (each lag must be < 0). If a dictionary is given, keys correspond to the component names (of first series when using multiple series) and the values correspond to the component lags(integer or list of integers).

lags_past_covariatesOne of int, list, dict, default=None

Number of lagged past_covariates values used to predict the next time step. If an integer is given the last lags_past_covariates past lags are used (inclusive, starting from lag -1). Otherwise a list of integers with lags < 0 is required. If a dictionary is given, keys correspond to the past_covariates component names(of first series when using multiple series) and the values correspond to the component lags(integer or list of integers).

lags_future_covariatesOne of tuple, list, dict, default=None

Number of lagged future_covariates values used to predict the next time step. If a tuple (past, future) is given the last past lags in the past are used (inclusive, starting from lag -1) along with the first future future lags (starting from 0 - the prediction time - up to future - 1 included). Otherwise a list of integers with lags is required. If dictionary is given, keys correspond to the future_covariates component names (of first series when using multiple series) and the values correspond to the component lags(integer or list of integers).

output_chunk_shiftint, default=0

Optionally, the number of steps to shift the start of the output chunk into the future (relative to the input chunk end). This will create a gap between the input (history of target and past covariates) and output. If the model supports future_covariates, the lags_future_covariates are relative to the first step in the shifted output chunk. Predictions will start output_chunk_shift steps after the end of the target series. If output_chunk_shift is set, the model cannot generate autoregressive predictions (n > output_chunk_length).

output_chunk_lengthint, default=1

Number of time steps predicted at once by the internal regression model. Does not have to equal the forecast horizon n used in predict(). However, setting output_chunk_length equal to the forecast horizon may be useful if the covariates don’t extend far enough into the future.

add_encodersdict, default=None

A large number of past and 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’ 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 SequentialEncoder to find out more about add_encoders. Default: None. An example showing some of add_encoders features:

add_encoders={
    'cyclic': {'future': ['month']},
    'datetime_attribute': {'future': ['hour', 'dayofweek']},
    'position': {'past': ['relative'], 'future': ['relative']},
    'custom': {'past': [lambda idx: (idx.year - 1950) / 50]},
    'transformer': Scaler()
}
model: object, default=None

Scikit-learn-like model with fit() and predict() methods. Also possible to use model that doesn’t support multi-output regression for multivariate timeseries, in which case one regressor will be used per component in the multivariate series. If None, defaults to: sklearn.linear_model.LinearRegression(n_jobs=-1).

multi_modelsbool, 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 at step ‘output_chunk_length’ in the future. Default: True.

use_static_covariatesbool, default=True

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 that all target series have the same static covariate dimensionality in fit() and predict().

past_covariateslist, default=None

column names in X which are known only for historical data, by default None

num_samplesint, default=1000

Number of times a prediction is sampled from a probabilistic model, by default 1000

Attributes:
cutoff

Cut-off = “present time” state of forecaster.

fh

Forecasting horizon that was passed.

is_fitted

Whether fit has been called.

state

State of the estimator.

Notes

If unspecified, all columns will be assumed to be known during prediction duration.

Methods

check_is_fitted([method_name])

Check if the estimator has been fitted.

clone()

Obtain a clone of the object with same hyper-parameters and config.

clone_tags(estimator[, tag_names])

Clone tags from another object as dynamic override.

convert_dataframe_to_timeseries(dataset)

Convert dataset for compatibility with darts.

convert_exogenous_dataset(dataset)

Make exogenous features to darts compatible, if available.

create_test_instance([parameter_set])

Construct an instance of the class, using first test parameter set.

create_test_instances_and_names([parameter_set])

Create list of all test instances and a list of names for them.

fit(y[, X, fh])

Fit forecaster to training data.

fit_predict(y[, X, fh, X_pred])

Fit and forecast time series at future horizon.

get_class_tag(tag_name[, tag_value_default])

Get class tag value from class, with tag level inheritance from parents.

get_class_tags()

Get class tags from class, with tag level inheritance from parent classes.

get_config()

Get config flags for self.

get_fitted_params([deep])

Get fitted parameters.

get_param_defaults()

Get object's parameter defaults.

get_param_names([sort])

Get object's parameter names.

get_params([deep])

Get a dict of parameters values for this object.

get_pretrained_params([deep])

Get pretrained parameters of this estimator.

get_tag(tag_name[, tag_value_default, ...])

Get tag value from instance, with tag level inheritance and overrides.

get_tags()

Get tags from instance, with tag level inheritance and overrides.

get_test_params([parameter_set])

Return testing parameter settings for the estimator.

is_composite()

Check if the object is composed of other BaseObjects.

load_from_path(serial)

Load object from file location.

load_from_serial(serial)

Load object from serialized memory container.

predict([fh, X])

Forecast time series at future horizon.

predict_interval([fh, X, coverage])

Compute/return prediction interval forecasts.

predict_proba([fh, X, marginal])

Compute/return fully probabilistic forecasts.

predict_quantiles([fh, X, alpha])

Compute/return quantile forecasts.

predict_residuals([y, X])

Return residuals of time series forecasts.

predict_var([fh, X, cov])

Compute/return variance forecasts.

pretrain(y[, X, fh])

Pre-train forecaster on panel (global) data.

reset()

Reset the object to a clean post-init state.

save([path, serialization_format])

Save serialized self to bytes-like object or to (.zip) file.

score(y[, X, fh])

Scores forecast against ground truth, using MAPE (non-symmetric).

set_config(**config_dict)

Set config flags to given values.

set_params(**params)

Set the parameters of this object.

set_random_state([random_state, deep, ...])

Set random_state pseudo-random seed parameters for self.

set_tags(**tag_dict)

Set instance level tag overrides to given values.

update(y[, X, update_params])

Update cutoff value and, optionally, fitted parameters.

update_predict(y[, cv, X, update_params, ...])

Make predictions and update model iteratively over the test set.

update_predict_single([y, fh, X, update_params])

Update model with new data and make forecasts.