axisnorm, axisexp, axisbernstein poi models#131
Merged
Conversation
…extened to --arg order...)
…automatic inclusion of Mu poi model
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
Adds three new param model classes (
AxisNormModel,AxisExpModel,AxisBernsteinModel) for per-cell signal normalization and exponential orfirst-order Bernstein polynomial background parameterization. All three classes
live in
rabbit/param_models/param_model.pyand are registered inrabbit/param_models/helpers.py. Multiple models can be composed on a singlefit via repeated
--paramModelflags, handled automatically byCompositeParamModel. Also fixesload_modelsto derive the composite'sallowNegativeParamfrom its sub-models rather than from the CLI flag, so axismodels that manage their own reparameterization internally are not incorrectly
squared by the fitter when composited.
Changes
param_model.pyAxisNormModel: new class. Assigns one independent normalization parameterper
(process, cell)where cells are defined by caller-specified axes lookedup from
indata.channel_info.allowNegativeParam=True; non-negativity isenforced by applying
tf.squareinsidecompute()(a softplus alternative iscommented out — avoids the zero-gradient saddle at
raw=0but both produceequivalent results at the minimum). Default raw =
sqrt(1) = 1sonorm=1at initialization. All other channels and processes are left at 1.0.
AxisExpModel: new class. Assigns per-celllnAmpland per-groupslopeparameters producing
rnorm = exp(lnAmpl + slope·x)across the shape axis.Both parameters are unconstrained reals (
allowNegativeParam=True); slope=0(flat background) is an interior point so the Hessian is non-degenerate there.
Slope can optionally be shared across a coarser axis grouping via an optional
5th CLI argument
slope_axes, reducing parameters and stabilizing the Hessianwhen per-cell slopes are under-constrained.
AxisBernsteinModel: new class. Assigns two non-negative parameters(c₀, c₁)per(process, cell)and producesrnorm(x_m) = c₀·(1−x_m) + c₁·x_m(first-order Bernstein polynomial) wherex_m ∈ [0,1]is the normalized mass bin center. Non-negativity is enforcedvia softplus applied inside
compute()(allowNegativeParam=True; rawoptimizer parameters are unconstrained reals). Default raw parameter is
softplus⁻¹(1) ≈ 0.5413, soc₀=c₁=1at initialization (flat unitbackground). An alternative
(lnAmpl, frac)parameterization is available ascommented-out code:
rnorm = 2·exp(lnAmpl)·[sigmoid(frac)·(1−x) + sigmoid(−frac)·x].This decouples overall amplitude from shape, reducing the near-null-space
dimensionality per near-empty cell from 2D to 1D (same structure as
AxisExpModel), at the cost of less directly interpretable parameters.param_models/helpers.pyRegisters
AxisNormModel,AxisExpModel, andAxisBernsteinModelin thebuilt-in model loader so they resolve without a full dotted module path.
load_modelsderives the composite'sallowNegativeParamasany(m.allowNegativeParam for m in models)so that axis models withallowNegativeParam=Trueare not incorrectly squared by the fitter when usedinside a
CompositeParamModel.Usage examples