swiftemulator.emulators.gaussian_process_mcmc module
Gaussian Process Emulator
- class swiftemulator.emulators.gaussian_process_mcmc.GaussianProcessEmulatorMCMC(kernel: Optional[Kernel] = None, mean_model: Optional[MeanModel] = None, burn_in_steps: int = 50, mcmc_steps: int = 100, walkers: int = 40, use_hyperparameter_error: bool = False, samples_for_error: int = 100)[source]
Bases:
BaseEmulatorGenerator for emulators for individual scaling relations.
- Parameters:
kernel – The
georgekernel to use. The GPE here uses a copy of this instance. By default, this is theExpSquaredKernelin Georgegeorge.kernels.Kernel – The
georgekernel to use. The GPE here uses a copy of this instance. By default, this is theExpSquaredKernelin Georgeoptional – The
georgekernel to use. The GPE here uses a copy of this instance. By default, this is theExpSquaredKernelin Georgemean_model – A mean model conforming to the
swiftemulatormean model protocol (several pre-made models are available in theswiftemulator.mean_modelsmodule).MeanModel – A mean model conforming to the
swiftemulatormean model protocol (several pre-made models are available in theswiftemulator.mean_modelsmodule).optional – A mean model conforming to the
swiftemulatormean model protocol (several pre-made models are available in theswiftemulator.mean_modelsmodule).burn_in_steps – Optional: Number of steps used for the burn-in part of the MCMC chain. Defaults to 50 for small intial test.
int – Optional: Number of steps used for the burn-in part of the MCMC chain. Defaults to 50 for small intial test.
optional – Optional: Number of steps used for the burn-in part of the MCMC chain. Defaults to 50 for small intial test.
mcmc_steps – Optional: Number of steps used for sampling the likelihood by the MCMC. chain. Defaults to 100 for small initial tests.
int – Optional: Number of steps used for sampling the likelihood by the MCMC. chain. Defaults to 100 for small initial tests.
optional – Optional: Number of steps used for sampling the likelihood by the MCMC. chain. Defaults to 100 for small initial tests.
walkers – Optional: Number of walkers used by the MCMC. Defaults to 40. Should (statistically) be at least 2 times the number of free parameters
int – Optional: Number of walkers used by the MCMC. Defaults to 40. Should (statistically) be at least 2 times the number of free parameters
optional – Optional: Number of walkers used by the MCMC. Defaults to 40. Should (statistically) be at least 2 times the number of free parameters
- use_hyperparameter_error, bool, optional
Switch for including errors originating from uncertain hyperparameters in the prediction outputs, (defaults to
False).- samples_for_error, int, optional
Number of MCMC samples to use for hyperparameter error estimation if
use_hyperparameter_errorisTrue, defaults to 100.
- kernel: Optional[Kernel]
- burn_in_steps: int
- mcmc_steps: int
- walkers: int
- use_hyperparameter_error: bool
- samples_for_error: int
- model_specification: Optional[ModelSpecification] = None
- model_parameters: Optional[ModelParameters] = None
- model_values: Optional[ModelValues] = None
- ordering: Optional[List[Hashable]] = None
- parameter_order: Optional[List[str]] = None
- independent_variables: Optional[array] = None
- dependent_variables: Optional[array] = None
- dependent_variable_errors: Optional[array] = None
- emulator: Optional[GP] = None
- fit_model(model_specification: ModelSpecification, model_parameters: ModelParameters, model_values: ModelValues)[source]
Fits the gaussian process model, as determined by the initialiser variables of the class (i.e. the kernel and the mean model).
- Parameters:
model_specification (ModelSpecification) – Full instance of the model specification.
model_parameters (ModelParameters) – Full instance of the model parameters.
model_values (ModelValues) – Full instance of the model values describing this individual scaling relation.
Notes
This method uses copies of the internal kernel and mean model objects, as those objects contain slightly unhelpful state information.
- plot_hyperparameter_distribution(filename=None, labels=None)[source]
Makes a cornerplot of the MCMC samples obtained when fitting the model
- Parameters:
filename – Name for the file to which the plot is saved. Optional, if None it will show the image.
None – Name for the file to which the plot is saved. Optional, if None it will show the image.
str – Name for the file to which the plot is saved. Optional, if None it will show the image.
labels – labels to add to the different plots. Optional, if None it will take the kernel names
None – labels to add to the different plots. Optional, if None it will take the kernel names
list[Hashable] – labels to add to the different plots. Optional, if None it will take the kernel names
Note
By using this function you solemnly swear to never try to infer anything from the hyperparameters, except whether they are converged.
- predict_values(independent: array, model_parameters: Dict[str, float]) array[source]
Predict values from the trained emulator contained within this object.
- Parameters:
independent – Independent continuous variables to evaluate the emulator at.
np.array – Independent continuous variables to evaluate the emulator at.
model_parameters (Dict[str, float]) – The point in model parameter space to create predicted values at.
- Returns:
dependent_predictions, np.array – Array of predictions, if the emulator is a function f, these are the predicted values of f(independent) evaluted at the position of the input model_parameters.
dependent_prediction_errors, np.array – Variance on the model predictions.