paddlets.ensemble.weighting_ensemble

class WeightingEnsembleBase(estimators: List[Tuple[object, dict]], mode='mean', verbose: bool = False)[source]

Bases: EnsembleBase

The WeightingEnsembleBase Class.

Parameters
  • estimators (List[Tuple[object, dict]]) – A list of tuple (class,params) consisting of several paddlets models

  • model – weighting mode, support [“mean”,”min”,”max”,”median”] for now, set to “mean” by default.

  • verbose (bool) – Turn on Verbose mode,set to true by default.

fit(train_tsdataset: TSDataset, valid_tsdataset: Optional[TSDataset] = None) None[source]

Fit

Parameters
  • train_tsdataset (TSDataset) – Train dataset.

  • valid_tsdataset (TSDataset, optional) – Valid dataset.

predict(tsdataset: TSDataset) TSDataset[source]
Parameters

tsdataset (TSDataset) – Dataset to predict.

class WeightingEnsembleForecaster(in_chunk_len: int, out_chunk_len: int, skip_chunk_len: int, estimators: List[Tuple[object, dict]], mode='mean', verbose: bool = False)[source]

Bases: WeightingEnsembleBase, BaseModel

The WeightingEnsembleForecaster 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. Bydefault, it will NOT skip any time steps.

  • estimators (List[Tuple[object, dict]]) – A list of tuple (class,params) consisting of several paddlets models

  • mode – weighting mode, support [“mean”,”min”,”max”,”median”] for now, set to “mean” by default.

  • verbose (bool) – Turn on Verbose mode,set to true by default.

fit(train_tsdataset: TSDataset, valid_tsdataset: Optional[TSDataset] = None) None[source]
Parameters
  • train_tsdataset (TSDataset) – Train dataset.

  • valid_tsdataset (TSDataset, optional) – Valid dataset.

predict(tsdataset: TSDataset) TSDataset[source]
Parameters

tsdataset (TSDataset) – Dataset to predict.

save(path: str, ensemble_file_name: str = 'paddlets-weighting-ensemble-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-weighting-ensemble-forecaster-partial.pkl') WeightingEnsembleForecaster[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.

class WeightingEnsembleAnomaly(in_chunk_len, estimators: List[Tuple[object, dict]], mode='mean', contamination: int = 0, standardization: bool = True, verbose: bool = False)[source]

Bases: WeightingEnsembleBase

The WeightingEnsembleAnomaly Class.

Parameters
  • in_chunk_len (int) – The size of the loopback window, i.e., the number of time steps feed to the model.

  • estimators (List[Tuple[object, dict]]) – A list of tuple (class,params) consisting of several paddlets Anomly models or Pyod models

  • model – weighting mode, support [“mean”,”min”,”max”,”median”] for now, set to “mean” by default.

  • contamination (int) – Anomaly rate, should in [0,0.5). For example, when anomaly rate=0.1, the top 10% values in trian scores will set to threshold. Set to 0 by default, use the max score on train as threshold.

  • standardization – bool, optional (default=True) If True, perform standardization first to convert prediction score to zero mean and unit variance.

  • verbose (bool) – Turn on Verbose mode,set to true by default.

fit(train_tsdataset: TSDataset, valid_tsdataset: Optional[TSDataset] = None) None[source]

Fit

Parameters
  • train_tsdataset (TSDataset) – Train dataset.

  • valid_tsdataset (TSDataset, optional) – Valid dataset.

predict(tsdataset: TSDataset) TSDataset[source]

Predict

Parameters

tsdataset (TSDataset) – Dataset to predict.

predict_score(tsdataset: TSDataset) TSDataset[source]

Get anomaly score on a batch. the result are output as tsdataset.

Parameters

tsdataset (TSDataset) – Data to be predicted.

Returns

TSDataset.

save(path: str, ensemble_file_name: str = 'paddlets-weighting-ensemble-anomly-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-weighting-ensemble-anomly-partial.pkl') WeightingEnsembleAnomaly[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.