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: BaseEmulator

Generator for emulators for individual scaling relations.

Parameters:
  • kernel – The george kernel to use. The GPE here uses a copy of this instance. By default, this is the ExpSquaredKernel in George

  • george.kernels.Kernel – The george kernel to use. The GPE here uses a copy of this instance. By default, this is the ExpSquaredKernel in George

  • optional – The george kernel to use. The GPE here uses a copy of this instance. By default, this is the ExpSquaredKernel in George

  • mean_model – A mean model conforming to the swiftemulator mean model protocol (several pre-made models are available in the swiftemulator.mean_models module).

  • MeanModel – A mean model conforming to the swiftemulator mean model protocol (several pre-made models are available in the swiftemulator.mean_models module).

  • optional – A mean model conforming to the swiftemulator mean model protocol (several pre-made models are available in the swiftemulator.mean_models module).

  • 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_error is True, defaults to 100.

kernel: Optional[Kernel]
mean_model: Optional[MeanModel]
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.