dsi
Data Space Inversion (DSI) emulator implementation.
DSI
Bases: Emulator
Data Space Inversion (DSI) emulator class. Based on DSI as described in Sun & Durlofsky (2017) and Sun et al (2017).
__init__(pst=None, data=None, transforms=None, energy_threshold=1.0, rowwise_groups=None, rowwise_fit_groups=None, feature_range=(-1, 1), verbose=False)
Initialize the DSI emulator.
If rowwise_groups is provided, training data are row-wise scaled per-group before SVD. Predictions are returned in scaled space and then inverse-scaled using per-row parameters derived from truth values found in pst.observation_data.
Parameters
pst : Pst, optional A Pst object. If provided, the emulator will be initialized with the information from the Pst object. data : DataFrame or ObservationEnsemble, optional An ensemble of simulated observations. If provided, the emulator will be initialized with the information from the ensemble. 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. energy_threshold : float, optional The energy threshold for the SVD. Default is 1.0, no truncation. rowwise_groups : dict, optional Dictionary mapping groups to column lists for row-wise scaling. rowwise_fit_groups : dict, optional Dictionary mapping groups to column lists for fitting row-wise scalers. feature_range : tuple, optional Feature range for row-wise scaling. Default is (-1, 1). verbose : bool, optional If True, enable verbose logging. Default is False.
check_for_pdc()
Check for Prior data conflict.
compute_projection_matrix(energy_threshold=None)
Compute the projection matrix using SVD.
Parameters
energy_threshold : float, optional Energy threshold for truncation. Default is None, which uses the threshold from initialization.
Returns
None
fit()
Fit the emulator to training data.
Parameters
self : DSI The DSI emulator instance.
Returns
self : DSI The fitted emulator.
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(pvals, pst=None)
Generate predictions from the emulator.
Parameters
pvals : numpy.ndarray or pandas.Series Parameter values for prediction. pst : Pst, optional If provided (or if self.observation_data exists), used to obtain truth values for inverse row-wise scaling (if enabled).
Returns
pandas.Series Predicted observation values.
prepare_dsivc(decvar_names, t_d=None, pst=None, oe=None, track_stack=False, dsi_args=None, percentiles=[0.25, 0.75, 0.5], mou_population_size=None, ies_exe_path='pestpp-ies')
Prepare Data Space Inversion Variable Control (DSIVC) control files.
Parameters
decvar_names : list or str Names of decision variables. t_d : str, optional Template directory path. pst : Pst, optional PST control file object. oe : ObservationEnsemble, optional Observation ensemble. track_stack : bool, optional Whether to track the stack. Default is False. dsi_args : dict, optional Arguments for DSI. percentiles : list, optional Percentiles to calculate. Default is [0.25, 0.75, 0.5]. mou_population_size : int, optional Population size for multi-objective optimization. ies_exe_path : str, optional Path to the PEST++ IES executable. Default is "pestpp-ies". Returns
Pst PEST++ control file object for DSIVC.
prepare_pestpp(t_d, observation_data=None, use_runstor=False, pst=None, verbose=False)
Prepare PEST++ interface for DSI. Overrides base method to handle specific DSI arguments like use_runstor
save(filename)
Save the fitted emulator to a file.
Parameters
filename : str Path to save the emulator.