feat: over/under-prediction policies for point-source pairing likelihoods#586
Merged
Conversation
…oods FitPositionsImagePairRepeat (model-fit default) gains an unmatched_model_policy class attribute: 'magnification_filter' (default — extra model images below magnification_threshold=0.1 are exempt, the demagnified-central convention; brighter extras add distance-to-nearest-observed residuals normalized by mean noise), 'penalize' (no exemption), 'ignore' (historical behaviour, explicit). Under-prediction gains a finite no_image_residual floor (1e4) when the solver returns no images. n_unmatched_model_positions diagnostic added. residual_map vectorized, fixed-shape/NaN-mask JAX-safe. FitPositionsImagePair (Hungarian): unmatched observed positions (n_model < n_obs) now contribute distance-to-nearest-model residuals in data order — previously silently dropped, rewarding under-prediction (removes the long- standing all-caps do-not-use warning). 5 new regression tests (exact penalty values, policy switching, demagnified exemption via IsothermalSph, no-image floors, Hungarian anti-reward). Full suite 358 pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PUuWXiS23FvmfQPLvMNjeM
This was referenced Jul 9, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deliberate over/under-prediction handling for the point-source image-plane likelihoods (issue #585; PyAutoMind
feature/cluster/10_solver_over_under_prediction.md). The audit on the issue found the model-fit default silently ignored extra model images and the Hungarian scheme actively rewarded under-predicting models (its own docstring carried an all-caps do-not-use warning about it).API Changes
FitPositionsImagePairRepeatgains anunmatched_model_policyclass attribute —"magnification_filter"(new default: extra model images with |μ| <magnification_threshold=0.1 are exempt per the demagnified-central observational convention, brighter extras add distance-to-nearest-observed penalty residuals),"penalize","ignore"(the historical behaviour, now explicit) — plus ano_image_residualfinite floor when the solver returns no images and ann_unmatched_model_positionsdiagnostic.FitPositionsImagePair(Hungarian) now penalizes unmatched observed positions instead of dropping them. Behaviour change: fits where the max-likelihood model over-predicts bright images or under-predicts will report (correctly) worse likelihoods than before; equal-count well-matched fits are numerically unchanged (regression-tested).See full details below.
Test Plan
Validation checklist (--auto run — in-session directives)
magnification_filterthe right default (vsignorepreserving old numbers)?Full API Changes
Added
FitPositionsImagePairRepeat.unmatched_model_policy(class attr, default"magnification_filter"),.magnification_threshold(0.1),.no_image_residual(1e4),.unmatched_model_mask,.unmatched_model_penalty_map,.n_unmatched_model_positions.FitPositionsImagePair.no_image_residual(1e4).Changed Behaviour
FitPositionsImagePairRepeat.chi_squared— adds the unmatched-model penalty term under non-ignorepolicies; unchanged when every model image is matched.FitPositionsImagePairRepeat.residual_map— vectorized; returns theno_image_residualfloor when the solver yields no finite images (previously crashed/NaN'd).FitPositionsImagePair.residual_map— unmatched observed positions contribute distance-to-nearest-model residuals in data order (previously dropped, rewarding under-prediction); NaN model rows filtered; no-image floor.Migration
unmatched_model_policy = "ignore"and pass viaAnalysisPoint(fit_positions_cls=...).🤖 Generated with Claude Code