The MultiOutputGP Class¶
Implementation of a multiple-output Gaussian Process Emulator.
Essentially a parallelized wrapper for the predict method. To fit
in parallel, use the fit_GP_MAP routine
Required arguments are inputs and targets, both of which
must be numpy arrays. inputs can be 1D or 2D (if 1D, assumes
second axis has length 1). targets can be 1D or 2D (if 2D,
assumes a single emulator and the first axis has length 1).
Optional arguments specify how each individual emulator is
constructed, including the mean function, kernel, priors, and how
to handle the nugget. Each argument can take values allowed by the
base GaussianProcess class, in which case all emulators are
assumed to use the same value. Any of these arguments can
alternatively be a list of values with length matching the number
of emulators to set those values individually.
Additional keyword arguments include inputdict, and
use_patsy, which control how strings are parsed to mean
functions, if using.
-
class
mogp_emulator.MultiOutputGP.MultiOutputGP(inputs, targets, mean=None, kernel=<mogp_emulator.Kernel.SquaredExponential object>, priors=None, nugget='adaptive', inputdict={}, use_patsy=True, use_gpu=False)¶ Implementation of a multiple-output Gaussian Process Emulator.
Essentially a parallelized wrapper for the predict method. To fit in parallel, use the
fit_GP_MAProutineRequired arguments are
inputsandtargets, both of which must be numpy arrays.inputscan be 1D or 2D (if 1D, assumes second axis has length 1).targetscan be 1D or 2D (if 2D, assumes a single emulator and the first axis has length 1).Optional arguments specify how each individual emulator is constructed, including the mean function, kernel, priors, and how to handle the nugget. Each argument can take values allowed by the base
GaussianProcessclass, in which case all emulators are assumed to use the same value. Any of these arguments can alternatively be a list of values with length matching the number of emulators to set those values individually.Additional keyword arguments include
inputdict, anduse_patsy, which control how strings are parsed to mean functions, if using.-
__init__(inputs, targets, mean=None, kernel=<mogp_emulator.Kernel.SquaredExponential object>, priors=None, nugget='adaptive', inputdict={}, use_patsy=True, use_gpu=False)¶ Create a new multi-output GP Emulator
-
get_emulators_fit()¶ Returns the emulators that have been fit
When a
MultiOutputGPclass is initialized, none of the emulators are fit. Fitting is done by passing the object to an external fitting routine, which modifies the object to fit the hyperparameters. Any emulators where the fitting fails are returned to the initialized state, and this method is used to obtain a list of emulators that have successfully been fit.Returns a list of
GaussianProcessobjects which have been fit (i.e. those which have a current valid set of hyperparameters).Returns: List of GaussianProcessobjects indicating the emulators that have been fit. If no emulators have been fit, returns an empty list.Return type: list of GaussianProcessobjects
-
get_emulators_not_fit()¶ Returns the indices of the emulators that have not been fit
When a
MultiOutputGPclass is initialized, none of the emulators are fit. Fitting is done by passing the object to an external fitting routine, which modifies the object to fit the hyperparameters. Any emulators where the fitting fails are returned to the initialized state, and this method is used to obtain a list of emulators that have not been fit.Returns a list of
GaussianProcessobjects which have not been fit (i.e. those which do not have a current set of hyperparameters).Returns: List of GaussianProcessobjects indicating the emulators that have not been fit. If all emulators have been fit, returns an empty list.Return type: list of GaussianProcessobjects
-
get_indices_fit()¶ Returns the indices of the emulators that have been fit
When a
MultiOutputGPclass is initialized, none of the emulators are fit. Fitting is done by passing the object to an external fitting routine, which modifies the object to fit the hyperparameters. Any emulators where the fitting fails are returned to the initialized state, and this method is used to determine the indices of the emulators that have succesfully been fit.Returns a list of non-negative integers indicating the indices of the emulators that have been fit.
Returns: List of integer indicies indicating the emulators that have been fit. If no emulators have been fit, returns an empty list. Return type: list of int
-
get_indices_not_fit()¶ Returns the indices of the emulators that have not been fit
When a
MultiOutputGPclass is initialized, none of the emulators are fit. Fitting is done by passing the object to an external fitting routine, which modifies the object to fit the hyperparameters. Any emulators where the fitting fails are returned to the initialized state, and this method is used to determine the indices of the emulators that have not been fit.Returns a list of non-negative integers indicating the indices of the emulators that have not been fit.
Returns: List of integer indicies indicating the emulators that have not been fit. If all emulators have been fit, returns an empty list. Return type: list of int
-
predict(testing, unc=True, deriv=True, include_nugget=True, allow_not_fit=False, processes=None)¶ Make a prediction for a set of input vectors
Makes predictions for each of the emulators on a given set of input vectors. The input vectors must be passed as a
(n_predict, D)or(D,)shaped array-like object, wheren_predictis the number of different prediction points under consideration andDis the number of inputs to the emulator. If the prediction inputs array has shape(D,), then the method assumesn_predict == 1. The prediction points are passed to each emulator and the predictions are collected into an(n_emulators, n_predict)shaped numpy array as the first return value from the method.Optionally, the emulator can also calculate the uncertainties in the predictions (as a variance) and the derivatives with respect to each input parameter. If the uncertainties are computed, they are returned as the second output from the method as an
(n_emulators, n_predict)shaped numpy array. If the derivatives are computed, they are returned as the third output from the method as an(n_emulators, n_predict, D)shaped numpy array. Finally, if uncertainties are computed, theinclude_nuggetflag determines if the uncertainties should include the nugget. By default, this is set toTrue.The
allow_not_fitflag determines how the object handles any emulators that do not have fit hyperparameter values (because fitting presumably failed). By default,allow_not_fit=Falseand the method will raise an error if any emulators are not fit. Passingallow_not_fit=Truewill override this andNaNwill be returned from any emulators that have not been fit.As with the fitting, this computation can be done independently for each emulator and thus can be done in parallel.
Parameters: - testing (ndarray) – Array-like object holding the points where
predictions will be made. Must have shape
(n_predict, D)or(D,)(for a single prediction) - unc (bool) – (optional) Flag indicating if the uncertainties
are to be computed. If
Falsethe method returnsNonein place of the uncertainty array. Default value isTrue. - deriv (bool) – (optional) Flag indicating if the derivatives
are to be computed. If
Falsethe method returnsNonein place of the derivative array. Default value isTrue. - include_nugget (bool) – (optional) Flag indicating if the
nugget should be included in the
predictive variance. Only relevant if
unc = True. Default isTrue. - allow_not_fit (bool) – (optional) Flag that allows predictions
to be made even if not all emulators have
been fit. Default is
Falsewhich will raise an error if any unfitted emulators are present. - processes (int or None) – (optional) Number of processes to use when
making the predictions. Must be a positive
integer or
Noneto use the number of processors on the computer (default isNone)
Returns: PredictResultobject holding numpy arrays containing the predictions, uncertainties, and derivatives, respectively. Predictions and uncertainties have shape(n_emulators, n_predict)while the derivatives have shape(n_emulators, n_predict, D). If thedo_uncordo_derivflags are set toFalse, then those arrays are replaced byNone.Return type: - testing (ndarray) – Array-like object holding the points where
predictions will be made. Must have shape
-