Skip to content

Cap max training weights.#74

Merged
GernotMaier merged 12 commits into
mainfrom
max-weight
Jul 1, 2026
Merged

Cap max training weights.#74
GernotMaier merged 12 commits into
mainfrom
max-weight

Conversation

@GernotMaier

@GernotMaier GernotMaier commented Jun 28, 2026

Copy link
Copy Markdown
Member

The weighting pipeline now works as follows:

  1. Sparse energy bins are excluded

Energy bins with fewer than 100 training events receive weight zero. This prevents a bin containing only 13 events from influencing training as much as a bin containing hundreds of thousands.

  1. Energy weighting is softer

The old weighting was:

weight1 / count

It is now:

weight1 / sqrt(count)

For example, a bin with 100 times fewer events receives 10 times—not 100 times—the per-event weight.

  1. Combined weights are capped

Energy weights are still multiplied by the existing quadratic multiplicity weight:

multiplicity_weightDispNImages**2

The final event weight is capped at 50. This still emphasizes rare, high-multiplicity events but prevents individual events from dominating the fit.

  1. Mean weight remains one

After applying the cap, a normalization scale is calculated numerically so that:

mean(training_weights) == 1
max(training_weights) <= 50

This preserves the effective learning-rate scale.

  1. Validation uses consistent weights

Previously, training was weighted but early stopping used an unweighted validation RMSE. The model therefore optimized one objective while early stopping monitored another.

Validation events now receive weights derived from the training distribution:

  • Same energy-bin boundaries
  • Same energy-bin factors
  • Same multiplicity normalization
  • Same cap
  • Same normalization scale

These are passed through:

sample_weight_eval_set=[weights_train, weights_eval]

Thus early stopping now monitors the same weighted objective being trained.

  1. Additional diagnostics

Training logs now report:

  • Energy-bin populations
  • Resulting inverse-square-root factors
  • Combined training-weight statistics
  • Validation-weight statistics
  • Maximum weight and configured cap

The main implementation is in models.py, with focused coverage in test_train_regression_standardization.py.

@GernotMaier GernotMaier requested a review from Copilot June 28, 2026 15:49
@GernotMaier GernotMaier self-assigned this Jun 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread src/eventdisplay_ml/models.py Outdated
Comment thread src/eventdisplay_ml/models.py
GernotMaier and others added 3 commits July 1, 2026 15:14
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@GernotMaier GernotMaier marked this pull request as ready for review July 1, 2026 14:45
@GernotMaier GernotMaier merged commit 30c5adc into main Jul 1, 2026
3 checks passed
@GernotMaier GernotMaier deleted the max-weight branch July 1, 2026 19:03
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