paddlets.ensemble.stacking_ensemble
- class StackingEnsembleBase(estimators: List[Tuple[object, dict]], final_learner: Optional[Callable] = None, verbose: bool = False)[source]
Bases:
EnsembleBaseThe StackingEnsembleBase Class.
- Parameters
estimators (List[Tuple[object, dict]]) – A list of tuple (class,params) consisting of several paddlets models
final_learner (Callable) – The final learner on stack level 2, should be a sklearn-like regressor, set to GradientBoostingRegressor(max_depth=5) by default.
verbose (bool) – Turn on Verbose mode,set to true by default.
- class StackingEnsembleForecaster(in_chunk_len: int, out_chunk_len: int, skip_chunk_len: int, estimators: List[Tuple[object, dict]], final_learner: Optional[Callable] = None, use_backtest: bool = True, resampling_strategy: str = 'cv', split_ratio: Union[str, float] = 0.1, k_fold: Union[str, int] = 3, verbose: bool = False)[source]
Bases:
StackingEnsembleBase,BaseModelThe StackingEnsembleForecaster Class.
- Parameters
in_chunk_len (int) – The size of the loopback window, i.e., the number of time steps feed to the model.
out_chunk_len (int) – The size of the forecasting horizon, i.e., the number of time steps output by the model.
skip_chunk_len (int) – Optional, the number of time steps between in_chunk and out_chunk for a single sample. The skip chunk is neither used as a feature (i.e. X) nor a label (i.e. Y) for a single sample. By default, it will NOT skip any time steps.
estimators (List[Tuple[object, dict]]) – A list of tuple (class,params) consisting of several paddlets Forecasting models.
final_learner (Callable) – The final learner on stack level 2, should be a sklearn-like regressor, set to GradientBoostingRegressor(max_depth=5) by default.
resampling_strategy (str) – A string of resampling strategies.Supported resampling strategy are “cv”, “holdout”.
split_ratio (Union[str, float]) – The proportion of the dataset included in the validation split for holdout.The split_ratio should be in the range of (0, 1).
k_fold (Union[str, int]) – Number of folds for cv.The k_fold should be in the range of (0, 10], defaults to 3.
use_backtest (bool) – If use backtest on predictions.
verbose (bool) – Turn on Verbose mode,set to true by default.
- predict(tsdataset: TSDataset) TSDataset[source]
Predict
- Parameters
tsdataset (TSDataset) – Dataset to predict.
- save(path: str, ensemble_file_name: str = 'paddlets-stacking-forecaster-partial.pkl') None[source]
Save the ensemble model to a directory.
- Parameters
path (str) – Output directory path.
ensemble_file_name (str) – Name of ensemble object. This file contains meta information of ensemble model.
- static load(path: str, ensemble_file_name: str = 'paddlets-stacking-forecaster-partial.pkl') StackingEnsembleForecaster[source]
Load the ensemble model from a directory.
- Parameters
path (str) – Input directory path.
ensemble_file_name (str) – Name of ensemble object. This file contains meta information of ensemble.
- Returns
The loaded ensemble model.