swiftemulator.sensitivity.cross_check_bins module

Basic test for any emulator. Leave one simulation out and test how well the emulator fits those values.

class swiftemulator.sensitivity.cross_check_bins.CrossCheckBins(kernel: Optional[Kernel] = None, mean_model: Optional[MeanModel] = None, hide_progress: bool = True)[source]

Bases: object

Generator for emulators for leave one out checks.

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 – 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).

  • hide_progress (bool) – Option to display a tqdm bar when creating the emulators, Default is to hide progress bar.

kernel: Optional[Kernel]
mean_model: Optional[MeanModel]
hide_progress: bool
model_specification: ModelSpecification
model_parameters: ModelParameters
model_values: ModelValues
leave_out_order: Optional[List[int]] = None
cross_emulators: Optional[Dict[Hashable, GP]] = None
build_emulators(model_specification: ModelSpecification, model_parameters: ModelParameters, model_values: ModelValues)[source]

Build a dictonary with an emulator for each simulation where the data of that simulation is left out

Note: this can take a long time

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.

plot_results(output_path: Optional[Union[str, Path]] = None, xlabel: Optional[str] = None, ylabel: Optional[str] = None)[source]

Make a plot of each of the leave_out emulators vs the original data.

Parameters:
  • output_path (Union[str, Path], optional) – Optional, name of the folder where you want to save the figures.

  • xlabel (str, optional) – Label for horizontal axis on the resultant figure.

  • ylabel (str, optional) – Label for vertical axis on the resultant figure.

get_mean_squared(use_dependent_error: bool = False, use_y_as_error: bool = False, use_squared_difference: bool = True)[source]

Calculates the mean squared per simulation and the total mean squared of the entire set of left-out simulations.

Parameters:
  • use_dependent_error (bool) – Use the simulation errors as weights for the mean squared calculation. Default is false.

  • use_y_as_error (boolean) – Use the model y values as the weights for the calculation.

  • use_squared_difference (boolean) – Use the simulation errors as weights for the mean squared calculation. Default is false.

Returns:

  • total_square_mean (float) – Mean (square) error across the bins.

  • mean_squared_dict (Dict[Hashable, float]) – Error per unique identifier.