optimpv.posterior package

Submodules

optimpv.posterior.posterior module

Module containing classes and functions for posterior analysis of parameters using the ML models from the BO optimization. This module provides functionality to visualize the posterior distributions of parameters using various plots, including 1D and 2D posteriors, devil’s plots, and density plots.

optimpv.posterior.posterior.calculate_1d_posteriors(mse_array)[source]

Calculate 1D posterior distributions over each parameter axis from an n x n-dimensional MSE array.

Parameters:

mse_array (np.ndarray) – An n-dimensional array of MSE values.

Returns:

A list of 1D posterior distributions for each parameter.

Return type:

list

optimpv.posterior.posterior.calculate_2d_posteriors(mse_array)[source]

Calculate 2D posterior distributions over each pair of parameter axes from an n x n-dimensional MSE array.

Parameters:

mse_array (np.ndarray) – An n-dimensional array of MSE values.

Returns:

A list of 2D posterior distributions for each pair of parameters.

Return type:

list

optimpv.posterior.posterior.devils_plot(params, Nres, objective_name, model, loss, best_parameters=None, params_orig=None, grid_MSE=None, dims_GP=None, optimizer_type='ax', **kwargs)[source]

Generate a devil’s plot to visualize the posterior distributions of parameters.

Parameters:
  • params (list of FitParam() objects) – List of parameters to explore.

  • Nres (int) – Number of points to evaluate for each parameter.

  • objective_name (str) – Name of the objective to evaluate.

  • model (torch model) – Model to evaluate the objective.

  • loss (str) – Loss function used, see optimpv/general/general.py for available loss functions.

  • best_parameters (dict, optional) – Dictionary of the best parameters, by default None.

  • params_orig (dict, optional) – Dictionary of the original parameters, by default None.

  • optimizer_type (str, optional) – Type of optimizer used, by default ‘ax’.

  • **kwargs (dict) – Additional keyword arguments.

Returns:

  • matplotlib.figure.Figure – The figure object containing the plot.

  • matplotlib.axes._subplots.AxesSubplot – The axes object containing the plot.

optimpv.posterior.posterior.get_MSE_grid(params, Nres, objective_name, model, loss, optimizer_type='ax')[source]

Calculate the Mean Squared Error (MSE) grid for the given parameters and model.

Parameters:
  • params (list of FitParam() objects) – List of parameters to explore.

  • Nres (int) – Number of points to evaluate for each parameter.

  • objective_name (str) – Name of the objective to evaluate.

  • model (torch model) – Model to evaluate the objective.

  • loss (str) – Loss function used, see optimpv/general/general.py for available loss functions.

  • optimizer_type (str, optional) – Type of optimizer used, by default ‘ax’

Returns:

Grid of MSE values.

Return type:

np.ndarray

Raises:

ValueError – If the optimizer type is not recognized.

optimpv.posterior.posterior.plot_1D_2D_posterior(params, param_x, param_y, Nres, objective_name, model, loss, best_parameters=None, params_orig=None, optimizer_type='ax', **kwargs)[source]

Generate a combined 2D and 1D posterior plot for a specific combination of 2 parameters.

Parameters:
  • params (list of FitParam() objects) – List of parameters to explore.

  • param_x (str) – Name of the parameter to plot on the x-axis.

  • param_y (str) – Name of the parameter to plot on the y-axis.

  • Nres (int) – Number of points to evaluate for each parameter.

  • objective_name (str) – Name of the objective to evaluate.

  • model (torch model) – Model to evaluate the objective.

  • loss (str) – Loss function used, see optimpv/general/general.py for available loss functions.

  • best_parameters (dict, optional) – Dictionary of the best parameters, by default None.

  • params_orig (dict, optional) – Dictionary of the original parameters, by default None.

  • optimizer_type (str, optional) – Type of optimizer used, by default ‘ax’.

  • **kwargs (dict) – Additional keyword arguments.

Returns:

  • matplotlib.figure.Figure – The figure object containing the plot.

  • matplotlib.axes._subplots.AxesSubplot – The axes object containing the plot.

optimpv.posterior.posterior.plot_1d_posteriors(params, Nres, objective_name, model, loss, best_parameters=None, params_orig=None, optimizer_type='ax', **kwargs)[source]

Generate 1D posterior plots for each parameter.

Parameters:
  • params (list of FitParam() objects) – List of parameters to explore.

  • Nres (int) – Number of points to evaluate for each parameter.

  • objective_name (str) – Name of the objective to evaluate.

  • model (torch model) – Model to evaluate the objective.

  • loss (str) – Loss function used, see optimpv/general/general.py for available loss functions.

  • best_parameters (dict, optional) – Dictionary of the best parameters, by default None.

  • params_orig (dict, optional) – Dictionary of the original parameters, by default None.

  • optimizer_type (str, optional) – Type of optimizer used, by default ‘ax’.

  • **kwargs (dict) – Additional keyword arguments.

Returns:

  • matplotlib.figure.Figure – The figure object containing the plot.

  • matplotlib.axes._subplots.AxesSubplot – The axes object containing the plot.

optimpv.posterior.posterior.plot_density_exploration(params, optimizer=None, best_parameters=None, params_orig=None, optimizer_type='ax', **kwargs)[source]

Generate density plots to visualize the exploration of parameter space.

Parameters:
  • params (list of FitParam() objects) – List of parameters to explore.

  • optimizer (object, optional) – Optimizer object, by default None.

  • best_parameters (dict, optional) – Dictionary of the best parameters, by default None.

  • params_orig (dict, optional) – Dictionary of the original parameters, by default None.

  • optimizer_type (str, optional) – Type of optimizer used, by default ‘ax’.

  • **kwargs (dict) – Additional keyword arguments.

Returns:

  • matplotlib.figure.Figure – The figure object containing the plot.

  • matplotlib.axes._subplots.AxesSubplot – The axes object containing the plot.

Raises:

ValueError – If the optimizer type is not supported.

Module contents