Skip to content

base

Base class for emulators.

Emulator

Base class for emulators.

This class defines the common interface for all emulator implementations and provides shared functionality used by multiple emulator types.

__init__(transforms=None, verbose=True)

Initialize the Emulator base class.

Parameters

transforms : list of dict, optional List of transformation specifications. Each dict should have: - 'type': str - Type of transformation (e.g.,'log10', 'normal_score'). - 'columns': list of str,optional - Columns to apply the transformation to. If not supplied, transformation is applied to all columns. - Additional kwargs for the transformation (e.g., 'quadratic_extrapolation' for normal score transform). Example: transforms = [ {'type': 'log10', 'columns': ['obs1', 'obs2']}, {'type': 'normal_score', 'quadratic_extrapolation': True} ] Default is None, which means no transformations will be applied. verbose : bool, optional If True, enable verbose logging. Default is True.

fit(X, y=None)

Fit the emulator to training data.

Parameters

X : pandas.DataFrame Input features for training. y : pandas.DataFrame or None, optional Target values for training if separate from X.

Returns

self : Emulator Returns self for method chaining.

load(filename) classmethod

Load a fitted emulator from a file.

Parameters

filename : str Path to the saved emulator file.

Returns

Emulator The loaded emulator instance.

predict(X)

Generate predictions using the fitted emulator.

Parameters

X : pandas.DataFrame Input data to generate predictions for.

Returns

pandas.DataFrame or pandas.Series Predictions for the input data.

prepare_pestpp(t_d, pst=None, verbose=False, **kwargs)

Generic method to prepare a PEST++ interface for the emulator.

This method automates the creation of template files, instruction files, control files, and the forward run script needed to run the emulator within a PEST++ workflow (e.g. IES).

Parameters

t_d : str Path to the template directory where files will be written. pst : Pst, optional A Pst object representing the original control file. Useful for scraping constraint weights, observation lists, etc. Subclasses may use this to determine specific parameters or observations. verbose : bool Enable verbose logging.

Returns

Pst The generated Pst object for the emulator.

save(filename)

Save the fitted emulator to a file.

Parameters

filename : str Path to save the emulator.