autoemulate.core.compare#

class AutoEmulate(x, y, models=None, x_transforms_list=None, y_transforms_list=None, model_tuning=True, model_kwargs=None, n_iter=10, n_splits=5, shuffle=True, n_bootstraps=100, max_retries=3, device=None, random_seed=None, log_level='progress_bar')[source]#

Bases: ConversionMixin, TorchDeviceMixin, Results

Automated emulator fitting.

The AutoEmulate class is the main class of the AutoEmulate package. It is used to set up and compare different emulator models on a given dataset. It can also be used to summarise and visualise results, and to save and load models.

static all_emulators()[source]#

Return a list of all available emulators.

static list_emulators()[source]#

Return a dataframe with model names of all available emulators.

Returns:

DataFrame with columns [‘model_name’, ‘short_name’].

Return type:

pd.DataFrame

get_models(models=None)[source]#

Return a list of the model classes for comparisons.

get_transforms(transforms)[source]#

Process and return a list of transforms.

filter_models_if_multioutput(models, warn)[source]#

Filter models to only include those that support multi-output data.

log_compare(best_model_name, x_transforms, y_transforms, best_params_for_this_model, r2_score, rmse_score)[source]#

Log the comparison results.

compare()[source]#

Compare different models on the provided dataset.

The method will: - Loop over all combinations of x and y transforms and models. - Set up the tuner with the training/validation data. - Tune hyperparameters for each model. - Fit the best model with the tuned hyperparameters. - Evaluate the performance of the best model on the test data. - Log the results. - Save the best model and its parameters.

plot(model_obj, input_index=None, output_index=None, figsize=None, n_cols=3)[source]#

Plot the evaluation of the model with the given result_id.

Parameters:
  • model_obj (int | Emulator | Result) – The model to plot. Can be an integer ID of a Result, an Emulator instance, or a Result instance.

  • input_index (int) – The index of the input feature to plot against the output.

  • output_index (int) – The index of the output feature to plot against the input.

save(model_obj, path=None, use_timestamp=True)[source]#

Save model to disk.

Parameters:
  • model_obj (int | Emulator | Result) – The model to save. Can be an integer ID of a Result, an Emulator instance, or a Result instance.

  • path (str) – Path to save the model.

  • use_timestamp (bool) – If True, appends a timestamp to the filename to ensure uniqueness.

load(path)[source]#

Load a stored model or result from disk.

Parameters:

path (str) – Path to model.

Returns:

The loaded model or result object.

Return type:

Emulator | Result