Skip to content

feat: over/under-prediction policies for point-source pairing likelihoods - #586

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/point-pairing-policies
Jul 9, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/point-pairing-policies

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

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

FitPositionsImagePairRepeat gains an unmatched_model_policy class 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 a no_image_residual finite floor when the solver returns no images and an n_unmatched_model_positions diagnostic. 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

  • 5 new regression tests: exact penalty values, policy switching via subclass, demagnified-central exemption (IsothermalSph), no-image finite floors (both schemes), Hungarian anti-reward with exact residuals.
  • Full PyAutoLens suite: 358 pass.
  • Workspace guide runs end-to-end demonstrating all three cases (companion PR).

Validation checklist (--auto run — in-session directives)

  • Effective level: supervised (header: supervised, cap: feature → supervised); "continue --auto"; design defaults batched on feat: point-source over/under-prediction handling in pairing likelihoods + cluster guide #585 (override there if wanted); Heart-ack carried in-session
  • Parallel-claim note: weak-small-datasets holds PyAutoLens (autolens/weak/ files) — disjoint from autolens/point/; re-verified at ship
  • Human: is magnification_filter the right default (vs ignore preserving old numbers)?
  • Human: merge, amend, or reject — then log the outcome
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-ignore policies; unchanged when every model image is matched.
  • FitPositionsImagePairRepeat.residual_map — vectorized; returns the no_image_residual floor 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

  • To reproduce pre-change likelihood values exactly: subclass with unmatched_model_policy = "ignore" and pass via AnalysisPoint(fit_positions_cls=...).

🤖 Generated with Claude Code

…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
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Jul 9, 2026
@Jammy2211
Jammy2211 merged commit 5b9b7c0 into main Jul 9, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/point-pairing-policies branch July 9, 2026 13:50
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
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