paddlets.automl.optimize_runner

class OptimizeRunner(search_alg: str = 'Random')[source]

Bases: object

Optimize runner is for experiment execution and hyperparameter tuning.

Parameters

search_alg (str) – The algorithm for optimization.Supported algorithms are “auto”, “Random”, “CMAES”, “TPE”, “CFO”, “BlendSearch”, “Bayes”.

setup_estimator(config: dict, paddlets_estimator: Union[Type[BaseModel], List[Union[Type[BaseTransform], Type[BaseModel]]]], in_chunk_len: int, out_chunk_len: int, skip_chunk_len: int, sampling_stride: int)[source]

Build a paddlets estimator with config.

Parameters
  • config (dict) – Algorithm configuration for estimator.

  • paddlets_estimator (Union[Type[BaseModel], List[Union[Type[BaseTransform], Type[BaseModel]]]]) – A class of a paddlets model or a list of classes consisting of several paddlets transformers and a paddlets model.

  • 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 – The number of time steps between in_chunk and out_chunk for a single sample.

  • sampling_stride (int) – Sampling intervals between two adjacent samples.

Returns

paddlets estimator.

Return type

BaseModel

optimize(paddlets_estimator: ~typing.Union[~typing.Type[~paddlets.models.base.BaseModel], ~typing.List[~typing.Union[~typing.Type[~paddlets.transform.base.BaseTransform], ~typing.Type[~paddlets.models.base.BaseModel]]]], in_chunk_len: int, out_chunk_len: int, train_tsdataset: ~typing.Union[~paddlets.datasets.tsdataset.TSDataset, ~typing.List[~paddlets.datasets.tsdataset.TSDataset]], valid_tsdataset: ~typing.Optional[~typing.Union[~paddlets.datasets.tsdataset.TSDataset, ~typing.List[~paddlets.datasets.tsdataset.TSDataset]]] = None, sampling_stride: int = 1, skip_chunk_len: int = 0, search_space: ~typing.Optional[dict] = None, metric: ~abc.ABCMeta = <class 'paddlets.metrics.metrics.MAE'>, mode: str = 'min', resampling_strategy: str = 'holdout', split_ratio: float = 0.1, k_fold: int = 3, n_trials: int = 5, cpu_resource: float = 1.0, gpu_resource: float = 0, max_concurrent_trials: int = 1, local_dir: ~typing.Optional[str] = None)[source]

Execute optimization.

Parameters
  • paddlets_estimator (Union[Type[BaseModel], List[Union[Type[BaseTransform], Type[BaseModel]]]]) – A class of a paddlets model or a list of classes consisting of several paddlets transformers and a paddlets model.

  • 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.

  • train_tsdataset (Union[TSDataset, List[TSDataset]]) – Train dataset.

  • valid_tsdataset (Union[TSDataset, List[TSDataset]], optional) – Valid dataset.

  • sampling_stride (int) – Sampling intervals between two adjacent samples.

  • skip_chunk_len (int) – Optional, the number of time steps between in_chunk and out_chunk for a single sample.

  • search_space (Optional[dict]) – The domain of the automl to be optimized.

  • metric (ABCMeta) – A class of a metric, e.g. MAE, MSE.

  • mode (str) – According to the mode, the metric is maximized or minimized. Supported mode are “min”, “max”

  • resampling_strategy (str) – A string of resampling strategies. Supported resampling strategy are “cv”, “holdout”.

  • split_ratio (float) – The proportion of the dataset included in the validation split for holdout.

  • k_fold (int) – Number of folds for cv.

  • n_trials (int) – The number of configurations suggested by the search algorithm.

  • cpu_resource (float) – CPU resources to allocate per trial.

  • gpu_resource (float) – GPU resources to allocate per trial. Note that GPUs will not be assigned if you do not specify them here.

  • max_concurrent_trials (int) – The maximum number of trials running concurrently.

  • local_dir (str) – Local dir to save training results to. Defaults to ./.

Returns

Object for experiment analysis.

Return type

ExperimentAnalysis

Raises

TuneError – Any trials failed.