Skip to content

feat: add window training modes for signal/background regions#8

Open
kratsg wants to merge 1 commit into
mainfrom
feat/window-training-modes
Open

feat: add window training modes for signal/background regions#8
kratsg wants to merge 1 commit into
mainfrom
feat/window-training-modes

Conversation

@kratsg

@kratsg kratsg commented Jul 25, 2025

Copy link
Copy Markdown
Contributor

Summary

  • Implements modes 3 and 4 from issue train cuts that select regions, also regions to reject #7
  • Adds automatic window learning to keep signal events (mode 3: window_keep)
  • Adds dual network approach to learn rejection windows for background events (mode 4: window_reject)
  • Maintains full backward compatibility with existing modes 1 and 2

Implementation Details

Mode 3: Window Keep (mode="window_keep")

  • Automatically duplicates each input feature to learn both upper and lower bounds
  • Uses fixed weights [+1, -1] pairs with learnable biases
  • Learns windows where signal events are kept: x1 < x < x2
  • Eliminates need to manually pass inputs twice with different signs
  • Returns cuts as (original_features, 2) shaped tensor

Mode 4: Window Reject (mode="window_reject")

  • Implements dual network architecture with acceptance and rejection networks
  • Acceptance network learns to keep signal (normal targets)
  • Rejection network learns windows to reject background
  • Final output: accept_prob * (1.0 - reject_prob)
  • Learns regions where background is rejected: x < x1 || x > x2

Architecture Changes

  • Enhanced OneToOneLinear with mode parameter and input expansion logic
  • Added DualNetworkLinear class for dual network approach
  • Updated EfficiencyScanNetwork to support different training modes
  • Modified loss functions to handle window cuts regularization properly
  • Preserved cabin's core philosophy of uncorrelated cuts in network

Test Plan

  • Unit tests for mode 3 (window_keep) functionality
  • Unit tests for mode 4 (window_reject) functionality
  • Backward compatibility tests for existing modes 1 and 2
  • All existing tests pass without modification
  • Cut shape validation for windowed modes
  • Training step validation for all modes

Usage Examples

# Mode 3: Learn windows to keep signal
efficnet = cabin.EfficiencyScanNetwork(
    features=10, 
    effics=[0.5, 0.7], 
    mode="window_keep"
)

# Mode 4: Learn rejection windows for background
efficnet = cabin.EfficiencyScanNetwork(
    features=10, 
    effics=[0.5, 0.7], 
    mode="window_reject"
)

🤖 Generated with Claude Code

Implements modes 3 and 4 from the GitHub issue to extend cabin's cut
learning capabilities:

- Mode 3 (window_keep): Automatically learn windows to keep signal events
  - Duplicates inputs to learn both upper and lower bounds (x1 < x < x2)
  - Uses fixed weights [+1, -1] pairs with learnable biases
  - Replaces need to manually pass inputs twice with different signs

- Mode 4 (window_reject): Learn rejection windows for background events
  - Dual network architecture: acceptance + rejection networks
  - Learns regions where (x < x1 || x > x2) to reject background
  - Final output: accept_prob * (1.0 - reject_prob)

Key changes:
- Enhanced OneToOneLinear with mode parameter and input expansion
- Added DualNetworkLinear class for dual network approach
- Updated EfficiencyScanNetwork to support different training modes
- Modified loss functions to handle window cuts regularization
- Comprehensive tests covering all modes with backward compatibility

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant