Skip to content

Simultaneous Multi-Category Binning Optimization#15

Open
akhter-towsifa wants to merge 9 commits intocms-flaf:mainfrom
akhter-towsifa:multi_bin_opt
Open

Simultaneous Multi-Category Binning Optimization#15
akhter-towsifa wants to merge 9 commits intocms-flaf:mainfrom
akhter-towsifa:multi_bin_opt

Conversation

@akhter-towsifa
Copy link
Copy Markdown

Currently, the binning optimization algorithm handles multi category cases in the following way:

  • takes the most sensistive category (i.e. res2b) in a given channel and finds the optimal binning with low expected limit,
  • freezes this optimal binning and uses it as a starting point for the next category (i.e. res1b),
  • calculates the best binning for the current category (i.e. res1b), freezes this one and uses it as a starting point for next category (i.e. boosted, and so on).

The current algorithm assumes some correlation in kinematics between the categories, but we want a more rigorous option that will optimize all the categories in a channel simultaneously.

  • This approach will be computationally heavy (evaluating limits over multiple categories at a time)
  • But will create a more consistent binning scheme throughout different categories.

@akhter-towsifa akhter-towsifa marked this pull request as ready for review February 25, 2026 15:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements simultaneous multi-category binning optimization for statistical inference, moving from a sequential approach where categories are optimized one-by-one to a simultaneous approach where all categories in a channel are optimized together. This is computationally heavier but produces more consistent binning schemes across categories.

Changes:

  • Adds new multi_optimize_binning.py module with MultiBinning and MultiBayesianOptimization classes for simultaneous multi-category optimization
  • Updates optimize_channel.py to support simultaneous multi-category optimization mode controlled by configuration
  • Replaces deprecated distutils.util.strtobool with a custom implementation in optimize_binning.py
  • Adds multi_category_optimization flag to bin_optimization.yaml configuration

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 16 comments.

File Description
bin_opt/multi_optimize_binning.py New file implementing simultaneous multi-category binning optimization with MultiBinning class and MultiBayesianOptimization algorithm
bin_opt/optimize_channel.py Adds multi-category optimization path, new helper functions for multi-category result selection and input file discovery
bin_opt/optimize_binning.py Replaces deprecated distutils.util.strtobool with custom implementation for Python 3.12+ compatibility
bin_opt/bin_optimization.yaml Adds multi_category_optimization configuration flag (set to True)
Comments suppressed due to low confidence (1)

bin_opt/optimize_channel.py:286

  • The variable other_cat_file is only assigned inside the inner loop (line 284) if a matching file is found. If no matching file exists in best_dir, the variable will be undefined when checked at line 286, causing a NameError. The check should be inside the loop or a default value should be set before the loop.
        for cat_idx in range(cat_index):
            cat = categories[cat_idx][0]
            for file in os.listdir(best_dir):
                if file.endswith('.txt') and cat in file:
                    other_cat_file = f"{best_dir}/{file}"

            if not os.path.isfile(other_cat_file):

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants