beetroots.approx_optim.approach_type package
Submodules
beetroots.approx_optim.approach_type.abstract_approach_type module
beetroots.approx_optim.approach_type.bo module
- class beetroots.approx_optim.approach_type.bo.BayesianOptimizationApproach[source]
Bases:
ApproachTypeimplements a Bayesian optimization approach to adjust the likelihood parameter
- optimization(first_points: List, init_points: int, n_iter: int, list_log10_f_grid: ndarray, pdf_kde_log10_f_Theta: ndarray, pbounds: Dict, sigma_a_val: float, sigma_m_val: float, n: int, ell: int) None[source]
performs Bayesian optimization
- Parameters:
first_points (List) – list of the points to evaluate before running the optimization
init_points (int) – number of init points
n_iter (int) – number of optimization steps to perform
list_log10_f_grid (np.ndarray) – _description_
pdf_kde_log10_f_Theta (np.ndarray) – _description_
pbounds (Dict) – Dictionary with parameters names as keys and a tuple with minimum and maximum values
sigma_a_val (float) – value of standard deviation of the additive Gaussian noise
sigma_m_val (float) – value of standard deviation of the multiplicative lognormal noise
n (int) – pixel index for which the optimization is performed
ell (int) – line index for which the optimization is performed
- plot_GP(bounds_a0_low: ndarray, bounds_a0_high: ndarray, bounds_a1_low: float, bounds_a1_high: float, n_iter: int) None[source]
plot the state (both mean and standard deviations) of the Gaussian process at multiple steps of the optimization process.
- Parameters:
bounds_a0_low (np.ndarray) – array of lower bounds on the transition location
bounds_a0_high (np.ndarray) – array of upper bounds on the transition location
bounds_a1_low (float) – lower bound on the transition slope
bounds_a1_high (float) – upper bound on the transition slope
n_iter (int) – number of performed optimization iterations
- plot_evaluation_points(bounds_a0_low: ndarray, bounds_a0_high: ndarray, bounds_a1_low: float, bounds_a1_high: float) None[source]
plots the sequence of sampled points with the order as colorbar
- Parameters:
bounds_a0_low (np.ndarray) – array of lower bounds on the transition location
bounds_a0_high (np.ndarray) – array of upper bounds on the transition location
bounds_a1_low (float) – lower bound on the transition slope
bounds_a1_high (float) – upper bound on the transition slope
- plots_postprocessing(bounds_a0_low: ndarray, bounds_a0_high: ndarray, bounds_a1_low: float, bounds_a1_high: float, n_iter: int) None[source]
makes some plots after the optimization process to facilitate the execution understanding
- Parameters:
bounds_a0_low (np.ndarray) – array of lower bounds on the transition location
bounds_a0_high (np.ndarray) – array of upper bounds on the transition location
bounds_a1_low (float) – lower bound on the transition slope
bounds_a1_high (float) – upper bound on the transition slope
n_iter (int) – number of performed optimization iterations
beetroots.approx_optim.approach_type.utils module
- beetroots.approx_optim.approach_type.utils.compute_lambda(a0: float, a1: float, f_Theta_true: float | ndarray) float | ndarray[source]
careful: a0 and a1 are in log, base 10, and computations require natural base
- Parameters:
a0 (float) – center of mixing interval
a1 (float) – radius of mixing interval
f_Theta_true (Union[float, np.ndarray]) – value of true \(f(\theta)\)
- Returns:
lambda – mixing parameter
- Return type:
Union[float, np.ndarray]
- beetroots.approx_optim.approach_type.utils.estimate_avg_dks_full_bo(a0: float, a1: float, list_log10_f_grid: ndarray, pdf_kde_log10_f_Theta: ndarray, sigma_a: float, sigma_m: float, N_samples_y: int, max_workers: int) float[source]
- beetroots.approx_optim.approach_type.utils.evaluate_cdf(y, a0, a1, f_Theta_true, sigma_a, sigma_m)[source]
- beetroots.approx_optim.approach_type.utils.evaluate_pdf(y, a0, a1, f_Theta_true, sigma_a, sigma_m)[source]
- beetroots.approx_optim.approach_type.utils.neg_log_pdf_add(y: float | ndarray, m_a: float | ndarray, s_a: float | ndarray) float | ndarray[source]
evaluates the negative log pdf of a Gaussian distribution
- Parameters:
y (Union[float, np.ndarray]) – points at which the pdf is to be evaluated
m_a (Union[float, np.ndarray]) – bias of the Gaussian distribution
s_a (Union[float, np.ndarray]) – standard deviation of the Gaussian distribution
- Returns:
negative log pdf
- Return type:
Union[float, np.ndarray]