pub struct TermCollectionDesign {Show 14 fields
pub design: DesignMatrix,
pub affine_offset: Array1<f64>,
pub penalties: Vec<BlockwisePenalty>,
pub nullspace_dims: Vec<usize>,
pub penaltyinfo: Vec<PenaltyBlockInfo>,
pub dropped_penaltyinfo: Vec<DroppedPenaltyBlockInfo>,
pub coefficient_lower_bounds: Option<Array1<f64>>,
pub linear_constraints: Option<LinearInequalityConstraints>,
pub intercept_range: Range<usize>,
pub linear_ranges: Vec<(String, Range<usize>)>,
pub linear_function_masses: Vec<Option<f64>>,
pub random_effect_ranges: Vec<(String, Range<usize>)>,
pub random_effect_levels: Vec<(String, Vec<u64>)>,
pub smooth: SmoothDesign,
}Fields§
§design: DesignMatrixThe full design matrix.
Prefer a true sparse matrix when every block is sparse-compatible. If the collection already contains intrinsically sparse blocks, preserve that storage and let PIRLS decide later whether the penalized system is sparse-native eligible. Purely dense materialized blocks still fall back to the lazy block operator when sparse storage would just re-encode a dense matrix.
affine_offset: Array1<f64>Known row-wise affine contribution to the linear predictor.
The realized predictor is affine_offset + design * beta. This channel
is deliberately separate from design: folding it into an estimated
intercept would make inhomogeneous term constraints coefficient-
dependent and would corrupt all linear-operator/Hessian identities.
penalties: Vec<BlockwisePenalty>§nullspace_dims: Vec<usize>§penaltyinfo: Vec<PenaltyBlockInfo>§dropped_penaltyinfo: Vec<DroppedPenaltyBlockInfo>§coefficient_lower_bounds: Option<Array1<f64>>Optional global coefficient lower bounds for constrained fitting.
Length equals design.ncols() when present. Unconstrained entries are -inf.
linear_constraints: Option<LinearInequalityConstraints>Optional global inequality constraints:
A * beta >= b.
intercept_range: Range<usize>§linear_ranges: Vec<(String, Range<usize>)>§linear_function_masses: Vec<Option<f64>>Per-linear-term empirical function mass used for this build’s ridge
penalty (parallel to spec.linear_terms; Some only for
double_penalty=true terms). This is the TRAINING-time value the
first (fit-time) build actually computed from data — never a value
recomputed from a prediction/rebuild call’s (possibly tiny or
zero-variance) rows. freeze_term_collection_from_design copies this
into each term’s frozen_function_mass so a later rebuild reuses it
instead of recomputing.
random_effect_ranges: Vec<(String, Range<usize>)>§random_effect_levels: Vec<(String, Vec<u64>)>§smooth: SmoothDesignImplementations§
Source§impl TermCollectionDesign
impl TermCollectionDesign
Sourcepub fn compose_offset(
&self,
base: ArrayView1<'_, f64>,
context: &str,
) -> Result<Array1<f64>, BasisError>
pub fn compose_offset( &self, base: ArrayView1<'_, f64>, context: &str, ) -> Result<Array1<f64>, BasisError>
Add this collection’s fixed affine channel to a caller-owned likelihood offset, validating the universal row/finite-value contract at the seam where the two offset sources become one.
Sourcepub fn apply(
&self,
beta: ArrayView1<'_, f64>,
) -> Result<Array1<f64>, BasisError>
pub fn apply( &self, beta: ArrayView1<'_, f64>, ) -> Result<Array1<f64>, BasisError>
Evaluate affine_offset + design * beta with a checked coefficient
width. Prediction/reporting code should use this instead of applying the
linear operator alone whenever it has no separate user offset channel.
Sourcepub fn leading_penalty_blocks_before_smooth(&self) -> usize
pub fn leading_penalty_blocks_before_smooth(&self) -> usize
Number of global penalty blocks that precede the smooth-term penalty blocks in the flat smoothing-parameter / EDF-trace layout.
The prefix is not the same as random_effect_ranges.len(): unpenalized
(or empty) random-effect ranges contribute coefficient columns but no
penalty block. The authoritative layout is the recorded penaltyinfo
sequence assembled alongside penalties.
Sourcepub fn smooth_term_penalty_range(
&self,
term_idx: usize,
) -> Result<Option<Range<usize>>, String>
pub fn smooth_term_penalty_range( &self, term_idx: usize, ) -> Result<Option<Range<usize>>, String>
Global flat-penalty range owned by one realized smooth term.
This is the only supported translation from a smooth-local penalty index to the model-global smoothing-parameter layout. The prefix comes from the metadata recorded alongside the matrices that were actually emitted; it must not be reconstructed from term specs or coefficient ranges, because unpenalized effects have columns but no penalty block.
Sourcepub fn penalties_as_penalty_matrix(&self) -> Vec<PenaltyMatrix>
pub fn penalties_as_penalty_matrix(&self) -> Vec<PenaltyMatrix>
Convert blockwise penalties to PenaltyMatrix::Blockwise without
expanding to p_total × p_total. This is the preferred path for
family modules that accept Vec<PenaltyMatrix>.
Sourcepub fn num_penalties(&self) -> usize
pub fn num_penalties(&self) -> usize
Number of penalty blocks.
Sourcepub fn realize_coefficient_groups(
&self,
groups: &[CoefficientGroupSpec],
base_prior: &RhoPrior,
) -> Result<RealizedCoefficientGroups, BasisError>
pub fn realize_coefficient_groups( &self, groups: &[CoefficientGroupSpec], base_prior: &RhoPrior, ) -> Result<RealizedCoefficientGroups, BasisError>
Resolve coefficient groups against this design’s global coefficient layout and append their penalties after the existing term penalties.
Sourcepub fn kronecker_penalty_system(&self) -> Option<KroneckerPenaltySystem>
pub fn kronecker_penalty_system(&self) -> Option<KroneckerPenaltySystem>
Extract a KroneckerPenaltySystem when the model’s only smooth term is
a single Kronecker-factored tensor.
This is a deliberate single-tensor fast path, not a partial feature: any
other shape — zero Kronecker terms, several of them, or a tensor mixed
with non-tensor smooth terms — is served correctly by the standard
block-separable assembly, so this returns None and the caller falls
back to it. The two former conditions (len != 1 and “a non-Kronecker
smooth term exists”) are jointly equivalent to “the sole smooth term is
Kronecker”, which the slice pattern below expresses directly in one pass.
Trait Implementations§
Source§impl Clone for TermCollectionDesign
impl Clone for TermCollectionDesign
Source§fn clone(&self) -> TermCollectionDesign
fn clone(&self) -> TermCollectionDesign
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for TermCollectionDesign
impl !UnwindSafe for TermCollectionDesign
impl Freeze for TermCollectionDesign
impl Send for TermCollectionDesign
impl Sync for TermCollectionDesign
impl Unpin for TermCollectionDesign
impl UnsafeUnpin for TermCollectionDesign
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.