Statistical_Analysis module
- class simple_one_syst_model.statistical_analysis.StatisticalAnalysis(model, bins=10, stat_only=False, systematics=None, fixed_syst=None)
Bases:
object
A class that performs statistical analysis on a given model and holdout set.
- Args:
model: The model used for prediction. holdout_set (dict): Dictionary containing holdout set data and labels. bins (int, optional): Number of bins for histogram calculation. Defaults to 10.
- Attributes:
model: The model used for prediction. bins (int): Number of bins for histogram calculation. syst_settings (dict): Dictionary containing the systematic settings. alpha_ranges (dict): Dictionary containing the alpha ranges for each systematic parameter. holdout_set (dict): Dictionary containing holdout set data and labels. fit_function_s (dict): Dictionary of lists containing the fit functions for signal events. fit_function_b (dict): Dictionary of lists containing the fit functions for background events. saved_info (dict): Dictionary containing the saved information for mu calculation.
- Methods:
compute_mu: Perform calculations to calculate mu. calculate_saved_info: Calculate the saved_info dictionary for mu calculation. nominal_histograms: Calculate the nominal histograms for signal and background events. fit_functions: Fits polynomial functions to the given data for a specific key. alpha_function: Calculate the alpha functions for signal and background events. save: Save the saved_info dictionary to a file. load: Load the saved_info dictionary from a file.
- alpha_function()
- calculate_saved_info(holdout_set, file_path)
Calculate the saved_info dictionary for mu calculation.
- Args:
model: The model used for prediction. train_set (dict): Dictionary containing training set data and labels. file_path (str, optional): File path to save the calculated saved_info dictionary. Defaults to “saved_info.pkl”.
- Returns:
dict: Dictionary containing calculated values of beta and gamma.
- compute_mu(score, weight, plot=None)
Perform calculations to calculate mu using the profile likelihood method.
- Args:
score (numpy.ndarray): Array of scores. weight (numpy.ndarray): Array of weights.
- Returns:
dict: Dictionary containing calculated values of mu_hat, delta_mu_hat, p16, and p84.
- load(file_path)
Load the saved_info dictionary from a file.
- Args:
file_path (str): File path to load the object.
- Returns:
None
- plot_stacked_histogram(bins, signal_fit, background_fit, mu, N_obs, save_name=None)
Plot a stacked histogram with combined signal and background fits and observed data points.
- Parameters:
bins (numpy.ndarray): Bin edges. signal_fit (numpy.ndarray): Combined signal fit values. background_fit (numpy.ndarray): Combined background fit values. mu (float): Multiplicative factor for the signal. N_obs (numpy.ndarray): Observed data points. save_name (str, optional): Name of the file to save the plot.
- save(file_path)
Save the saved_info dictionary to a file.
- Args:
file_path (str): File path to save the object.
- Returns:
None
- visualize_fit(alpha_list, array, coefficient_list, alpha_name=None, log_y=False, save_name=None)