DartsXGBModel
DartsXGBModel
- class DartsXGBModel(past_covariates: list[str] | None = None, num_samples: int | None = 1000, 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, add_encoders: dict | None = None, likelihood: str | None = None, quantiles: list[float] | None = None, random_state: int | None = None, multi_models: bool | None = True, use_static_covariates: bool | None = True, kwargs: dict | None = None)[source]
Darts XGBModel Estimator.
This is based on implementation of XGBoost Model in darts [1] by Unit8.
- Parameters:
- past_covariateslist, default=None
column names in
Xwhich 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
- 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_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’
Scalercan be added to transform the generated covariates. This happens all under one hood and only needs to be specified at model creation. ReadSequentialEncoderto find out more aboutadd_encoders. Default:None. An example showing some ofadd_encodersfeatures: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() }
- likelihoodstr, default=None
Can be set to poisson or quantile. If set, the model will be probabilistic, allowing sampling at prediction time. This will overwrite any objective parameter.
- quantileslist, default=None
Fit the model to these quantiles if the likelihood is set to quantile.
- random_stateint, default=None
Control the randomness in the fitting procedure and for sampling. Default:
None.- 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. IfTrue, and static covariates are available at fitting time, will enforce that all target series have the same static covariate dimensionality infit()andpredict().- kwargsdict, default=None
Additional keyword arguments passed to xgb.XGBRegressor. Passed as a dictionary to conform to sklearn’s API. Default:
None.
- Attributes:
cutoffCut-off = “present time” state of forecaster.
fhForecasting horizon that was passed.
is_fittedWhether
fithas been called.stateState of the estimator.
Notes
If unspecified, all columns will be assumed to be known during prediction duration.
References
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
dartscompatible, 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.

