zoo.automl.model package

Submodules

zoo.automl.model.MTNet_keras module

zoo.automl.model.Seq2Seq module

zoo.automl.model.Seq2Seq_pytorch module

class zoo.automl.model.Seq2Seq_pytorch.Decoder(output_dim, hidden_dim, layer_num, dropout)[source]

Bases: torch.nn.modules.module.Module

forward(decoder_input, hidden, cell)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class zoo.automl.model.Seq2Seq_pytorch.Encoder(input_dim, hidden_dim, layer_num, dropout)[source]

Bases: torch.nn.modules.module.Module

forward(input_seq)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class zoo.automl.model.Seq2Seq_pytorch.Seq2Seq(encoder, decoder, target_seq_len=1)[source]

Bases: torch.nn.modules.module.Module

forward(source, target=None)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class zoo.automl.model.Seq2Seq_pytorch.Seq2SeqPytorch(check_optional_config=True, future_seq_len=1)[source]

Bases: zoo.automl.model.abstract.BaseModel

evaluate(x, y, metric=['mse'])[source]

Evaluate on x, y :param x: input :param y: target :param metric: a list of metrics in string format :return: a list of metric evaluation results

fit_eval(x, y, validation_data=None, mc=False, verbose=0, **config)[source]

optimize and evaluate for one iteration for tuning :param config: tunable parameters for optimization :return:

predict(x, mc=False)[source]

Prediction on x. :param x: input :return: predicted y

predict_with_uncertainty(x, n_iter=100)[source]
restore(model_path, **config)[source]

restore model from file :param model_path: the model file :param config: the trial config :return: the restored model

save(model_path, config_path)[source]

save model to file. :param model_path: the model file. :param config_path: the config file :return:

zoo.automl.model.VanillaLSTM module

zoo.automl.model.VanillaLSTM_pytorch module

class zoo.automl.model.VanillaLSTM_pytorch.LSTMModel(input_dim, hidden_dim, layer_num, dropout, output_dim)[source]

Bases: torch.nn.modules.module.Module

forward(input_seq)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class zoo.automl.model.VanillaLSTM_pytorch.VanillaLSTMPytorch(check_optional_config=True, future_seq_len=1)[source]

Bases: zoo.automl.model.abstract.BaseModel

evaluate(x, y, metric=['mse'])[source]

Evaluate on x, y :param x: input :param y: target :param metric: a list of metrics in string format :return: a list of metric evaluation results

fit_eval(x, y, validation_data, mc=False, verbose=0, **config)[source]

optimize and evaluate for one iteration for tuning :param config: tunable parameters for optimization :return:

predict(x, mc=False)[source]

Prediction on x. :param x: input :return: predicted y

predict_with_uncertainty(x, n_iter=100)[source]
restore(model_path, **config)[source]

restore model from file :param model_path: the model file :param config: the trial config :return: the restored model

save(model_path, config_path)[source]

save model to file. :param model_path: the model file. :param config_path: the config file :return:

zoo.automl.model.XGBoostRegressor module

zoo.automl.model.abstract module

class zoo.automl.model.abstract.BaseModel[source]

Bases: abc.ABC

base model for automl tuning

check_optional_config = False
evaluate(x, y, metric=None)[source]

Evaluate the model :param x: input :param y: target :param metric: :return: a list of metric evaluation results

fit_eval(x, y, validation_data=None, mc=False, verbose=0, **config)[source]

optimize and evaluate for one iteration for tuning :param config: tunable parameters for optimization :return:

future_seq_len = None
predict(x, mc=False)[source]

Prediction. :param x: input :return: result

restore(model_path, **config)[source]

restore model from model file and config. :param model_path: the model file :param config: the config :return: the restored model

save(model_path, config_path, **config)[source]

save model to file. :param model_path: the model file path to be saved to. :param config_path: the config file path to be saved to. :return:

zoo.automl.model.tcmf_model module

class zoo.automl.model.tcmf_model.ModelWrapper[source]

Bases: object

evaluate(**kwargs)[source]
fit(**kwargs)[source]
is_distributed(**kwargs)[source]
load(**kwargs)[source]
predict(**kwargs)[source]
save(**kwargs)[source]
class zoo.automl.model.tcmf_model.TCMF[source]

Bases: zoo.automl.model.abstract.BaseModel

MF regularized TCN + TCN. This version is not for automated searching yet.

evaluate(x=None, y=None, metrics=None, num_workers=None)[source]

Evaluate on the prediction results and y. We predict horizon time-points ahead the input x in fit_eval before evaluation, where the horizon length equals the second dimension size of y. :param x: We don’t support input x currently. :param y: target. We interpret the second dimension of y as the horizon length for

evaluation.

Parameters
  • metrics – a list of metrics in string format

  • num_workers – the number of workers to use in evaluate. It defaults to 1.

Returns

a list of metric evaluation results

fit_eval(x, y=None, verbose=0, num_workers=None, **config)[source]

Fit on the training data from scratch. Since the rolling process is very customized in this model, we enclose the rolling process inside this method.

Parameters
  • x – training data, an array in shape (nd, Td), nd is the number of series, Td is the time dimension

  • y – None. target is extracted from x directly

  • verbose

  • num_workers – number of workers to use.

Returns

the evaluation metric value

fit_incremental(x)[source]

Incremental fitting given a pre-trained model. :param x: incremental data :param config: fitting parameters :return:

static get_default_num_workers()[source]
predict(x=None, horizon=24, mc=False, num_workers=None)[source]

Predict horizon time-points ahead the input x in fit_eval :param x: We don’t support input x currently. :param horizon: horizon length to predict :param mc: :param num_workers: the number of workers to use. Note that there has to be an activate

RayContext if num_workers > 1.

Returns

restore(model_file)[source]

restore model from model file and config. :param model_path: the model file :param config: the config :return: the restored model

save(model_file)[source]

save model to file. :param model_path: the model file path to be saved to. :param config_path: the config file path to be saved to. :return:

set_params(**config)[source]
class zoo.automl.model.tcmf_model.TCMFDistributedModelWrapper(config)[source]

Bases: zoo.automl.model.tcmf_model.ModelWrapper

evaluate(x, y, metric=None, num_workers=None)[source]

Evaluate the model :param x: input :param y: target :param metric: :param num_workers: :return: a list of metric evaluation results

fit(x, incremental=False, num_workers=None)[source]
is_distributed()[source]
load(model_path, minPartitions=None)[source]

restore model from model file and config. :param model_path: the model file :return: the restored model

predict(x, horizon=24, num_workers=None)[source]

Prediction. :param x: input :param horizon: :param num_workers :return: result

save(model_path)[source]

save model to file. :param model_path: the model file path to be saved to. :return:

class zoo.automl.model.tcmf_model.TCMFLocalModelWrapper(config)[source]

Bases: zoo.automl.model.tcmf_model.ModelWrapper

evaluate(x, y, metric=None, num_workers=None)[source]

Evaluate the model :param x: input :param y: target :param metric: :param num_workers: :return: a list of metric evaluation results

fit(x, incremental=False, num_workers=None)[source]
is_distributed()[source]
load(model_path)[source]

restore model from model file and config. :param model_path: the model file :return: the restored model

predict(x, horizon=24, num_workers=None)[source]

Prediction. :param x: input :param horizon :param num_workers :return: result

save(model_path)[source]

save model to file. :param model_path: the model file path to be saved to. :return:

zoo.automl.model.tcmf_model.split_id_and_train_data(d, is_distributed)[source]

zoo.automl.model.time_sequence module

Module contents