pub struct FittedModelPayload {Show 94 fields
pub version: u32,
pub formula: String,
pub model_kind: ModelKind,
pub family_state: FittedFamily,
pub family: String,
pub inference_notes: Vec<String>,
pub used_device: bool,
pub fit_result: Option<UnifiedFitResult>,
pub unified: Option<UnifiedFitResult>,
pub spline_scan: Option<SavedSplineScan>,
pub residual_cascade: Option<SavedResidualCascade>,
pub data_schema: Option<DataSchema>,
pub link: Option<InverseLink>,
pub mixture_link_param_covariance: Option<Vec<Vec<f64>>>,
pub sas_param_covariance: Option<Vec<Vec<f64>>>,
pub formula_noise: Option<String>,
pub formula_logslope: Option<String>,
pub formula_logslopes: Option<Vec<String>>,
pub offset_column: Option<String>,
pub noise_offset_column: Option<String>,
pub beta_noise: Option<Vec<f64>>,
pub noise_projection: Option<Vec<Vec<f64>>>,
pub noise_center: Option<Vec<f64>>,
pub noise_scale: Option<Vec<f64>>,
pub noise_non_intercept_start: Option<usize>,
pub noise_projection_ridge_alpha: Option<f64>,
pub gaussian_response_scale: Option<f64>,
pub linkwiggle_knots: Option<Vec<f64>>,
pub linkwiggle_degree: Option<usize>,
pub beta_link_wiggle: Option<Vec<f64>>,
pub baseline_timewiggle_knots: Option<Vec<f64>>,
pub baseline_timewiggle_degree: Option<usize>,
pub baseline_timewiggle_penalty_orders: Option<Vec<usize>>,
pub baseline_timewiggle_double_penalty: Option<bool>,
pub beta_baseline_timewiggle: Option<Vec<f64>>,
pub beta_baseline_timewiggle_by_cause: Option<Vec<Vec<f64>>>,
pub z_column: Option<String>,
pub z_columns: Option<Vec<String>>,
pub latent_z_normalization: Option<SavedLatentZNormalization>,
pub latent_score_contract: Option<SavedLatentScoreContract>,
pub latent_measure: Option<LatentMeasureKind>,
pub latent_z_rank_int_calibration: Option<LatentZRankIntCalibration>,
pub latent_z_conditional_calibration: Option<LatentZConditionalCalibration>,
pub marginal_baseline: Option<f64>,
pub logslope_baseline: Option<f64>,
pub logslope_baselines: Option<Vec<f64>>,
pub score_warp_runtime: Option<SavedCompiledFlexBlock>,
pub link_deviation_runtime: Option<SavedCompiledFlexBlock>,
pub influence_absorber_width: Option<usize>,
pub survival_entry: Option<String>,
pub survival_exit: Option<String>,
pub survival_event: Option<String>,
pub survivalspec: Option<String>,
pub survival_cause_count: Option<usize>,
pub survival_endpoint_names: Option<Vec<String>>,
pub survival_baseline_target: Option<String>,
pub survival_baseline_scale: Option<f64>,
pub survival_baseline_shape: Option<f64>,
pub survival_baseline_rate: Option<f64>,
pub survival_baseline_makeham: Option<f64>,
pub survival_time_basis: Option<String>,
pub survival_time_degree: Option<usize>,
pub survival_time_knots: Option<Vec<f64>>,
pub survival_time_keep_cols: Option<Vec<usize>>,
pub survival_time_smooth_lambda: Option<f64>,
pub survival_time_anchor: Option<f64>,
pub survivalridge_lambda: Option<f64>,
pub survival_likelihood: Option<String>,
pub survival_beta_time: Option<Vec<f64>>,
pub survival_beta_threshold: Option<Vec<f64>>,
pub survival_beta_log_sigma: Option<Vec<f64>>,
pub survival_noise_projection: Option<Vec<Vec<f64>>>,
pub survival_noise_center: Option<Vec<f64>>,
pub survival_noise_scale: Option<Vec<f64>>,
pub survival_noise_non_intercept_start: Option<usize>,
pub survival_noise_projection_ridge_alpha: Option<f64>,
pub survival_distribution: Option<ResidualDistribution>,
pub training_headers: Option<Vec<String>>,
pub training_table_kind: Option<String>,
pub training_feature_ranges: Option<Vec<(f64, f64)>>,
pub group_metadata: Option<GroupMetadata>,
pub deployment_extensions: Vec<SavedDeploymentExtension>,
pub transformation_response_knots: Option<Vec<f64>>,
pub transformation_response_transform: Option<Vec<Vec<f64>>>,
pub transformation_response_degree: Option<usize>,
pub transformation_response_median: Option<f64>,
pub transformation_score_calibration: Option<TransformationScoreCalibration>,
pub resolved_termspec: Option<TermCollectionSpec>,
pub resolved_termspec_noise: Option<TermCollectionSpec>,
pub resolved_termspec_logslope: Option<TermCollectionSpec>,
pub resolved_termspec_logslopes: Option<Vec<TermCollectionSpec>>,
pub adaptive_regularization_diagnostics: Option<AdaptiveRegularizationDiagnostics>,
pub gaussian_jackknife_plus: Option<GaussianJackknifePlusStats>,
pub full_conformal: Option<ExactFullConformalSubstrate>,
}Fields§
§version: u32§formula: String§model_kind: ModelKind§family_state: FittedFamily§family: String§inference_notes: Vec<String>Human-readable advisories produced while materializing this model —
e.g. an mgcv-style “k was reduced to the data support” note when a
cubic-regression marginal is capped, or a basis-degradation note. These
are surfaced to CLI users via print_inference_summary; persisting them
here lets the Python (gamfit) interface surface the SAME advisories as
warnings / model.notes instead of silently dropping them at the FFI
boundary (#1543). #[serde(default)] keeps older payloads (which had no
such field) deserializing cleanly as “no notes”.
used_device: bool§fit_result: Option<UnifiedFitResult>§unified: Option<UnifiedFitResult>Unified (family-agnostic) representation of the fit result.
spline_scan: Option<SavedSplineScan>Exact O(n) spline-scan fit representation (#1030/#1034): the
state-space smoothing-spline posterior of a single 1-D Gaussian
smooth. When Some, this standard Gaussian model’s predictions
replay the Gaussian bridge from this state and the model carries no
dense fit_result (the representations are mutually exclusive —
enforced by validate_for_persistence). #[serde(default)] so older
payloads read as: not a scan model.
residual_cascade: Option<SavedResidualCascade>O(n log n) multiresolution residual-cascade fit (#1032): the persisted
multilevel Wendland-frame state for a single scattered 2–3D Gaussian
smooth past the dense-kernel cliff. When Some, predictions replay the
cascade posterior; mutually exclusive with spline_scan/fit_result.
#[serde(default)] keeps forward-compatibility with older payloads.
data_schema: Option<DataSchema>§link: Option<InverseLink>§mixture_link_param_covariance: Option<Vec<Vec<f64>>>§sas_param_covariance: Option<Vec<Vec<f64>>>§formula_noise: Option<String>§formula_logslope: Option<String>§formula_logslopes: Option<Vec<String>>§offset_column: Option<String>§noise_offset_column: Option<String>§beta_noise: Option<Vec<f64>>§noise_projection: Option<Vec<Vec<f64>>>§noise_center: Option<Vec<f64>>§noise_scale: Option<Vec<f64>>§noise_non_intercept_start: Option<usize>§noise_projection_ridge_alpha: Option<f64>Tikhonov ridge alpha used by solve_scale_projection when fitting
noise_projection. Persisted so prediction-time replay is identical
to fit-time projection.
gaussian_response_scale: Option<f64>§linkwiggle_knots: Option<Vec<f64>>§linkwiggle_degree: Option<usize>§beta_link_wiggle: Option<Vec<f64>>§baseline_timewiggle_knots: Option<Vec<f64>>§baseline_timewiggle_degree: Option<usize>§baseline_timewiggle_penalty_orders: Option<Vec<usize>>§baseline_timewiggle_double_penalty: Option<bool>§beta_baseline_timewiggle: Option<Vec<f64>>§beta_baseline_timewiggle_by_cause: Option<Vec<Vec<f64>>>§z_column: Option<String>§z_columns: Option<Vec<String>>§latent_z_normalization: Option<SavedLatentZNormalization>§latent_score_contract: Option<SavedLatentScoreContract>§latent_measure: Option<LatentMeasureKind>§latent_z_rank_int_calibration: Option<LatentZRankIntCalibration>Optional rank-INT calibration for the latent score (BMS family).
When Some, the marginal-slope predictor routes the input z
through LatentZRankIntCalibration::apply_at_predict before the
closed-form standard-normal kernel, matching fit-time semantics.
#[serde(default)] so models persisted before this field existed
continue to deserialize cleanly (interpreted as: no calibration).
latent_z_conditional_calibration: Option<LatentZConditionalCalibration>Optional conditional location-scale calibration of the latent score
(#905, BMS family). When Some, the marginal-slope predictor replaces
the (normalized) input z by ζ = (z − m(C))/√v(C) — rebuilding the
conditioning span a(C) from the marginal prediction design — before
the closed-form standard-normal kernel, matching fit-time semantics.
Mutually exclusive with latent_z_rank_int_calibration. #[serde(default)]
so pre-existing models deserialize cleanly (interpreted as: no
conditional calibration).
marginal_baseline: Option<f64>§logslope_baseline: Option<f64>§logslope_baselines: Option<Vec<f64>>§score_warp_runtime: Option<SavedCompiledFlexBlock>§link_deviation_runtime: Option<SavedCompiledFlexBlock>§influence_absorber_width: Option<usize>Width p₁ of the survival marginal-slope absorbed Stage-1 influence block
(#461) when present (the dedicated trailing absorber block). Predict drops
its γ; this records the column count so the predictor can account for
the extra block and slice γ out of the joint covariance.
survival_entry: Option<String>§survival_exit: Option<String>§survival_event: Option<String>§survivalspec: Option<String>§survival_cause_count: Option<usize>§survival_endpoint_names: Option<Vec<String>>§survival_baseline_target: Option<String>§survival_baseline_scale: Option<f64>§survival_baseline_shape: Option<f64>§survival_baseline_rate: Option<f64>§survival_baseline_makeham: Option<f64>§survival_time_basis: Option<String>§survival_time_degree: Option<usize>§survival_time_knots: Option<Vec<f64>>§survival_time_keep_cols: Option<Vec<usize>>§survival_time_smooth_lambda: Option<f64>§survival_time_anchor: Option<f64>§survivalridge_lambda: Option<f64>§survival_likelihood: Option<String>§survival_beta_time: Option<Vec<f64>>§survival_beta_threshold: Option<Vec<f64>>§survival_beta_log_sigma: Option<Vec<f64>>§survival_noise_projection: Option<Vec<Vec<f64>>>§survival_noise_center: Option<Vec<f64>>§survival_noise_scale: Option<Vec<f64>>§survival_noise_non_intercept_start: Option<usize>§survival_noise_projection_ridge_alpha: Option<f64>Survival analog of noise_projection_ridge_alpha: the Tikhonov ridge
used when fitting the survival log-sigma projection.
survival_distribution: Option<ResidualDistribution>§training_headers: Option<Vec<String>>§training_table_kind: Option<String>Container type of the table the model was fitted on, as detected by the
Python binding ("pandas", "polars", "pyarrow", "numpy", or an
ambiguous tag such as "unknown"). This is presentation provenance, not
math: gamfit.Model.predict uses it as the output-container fallback
when the prediction input is itself container-ambiguous (a dict of
columns or a list of record dicts). Persisting it in the model payload
makes the fallback survive save/load and dumps/loads, so a
reloaded model predicts into the same container as the in-memory one.
None for older payloads (and for fits that never recorded a kind), in
which case the fallback degrades to "dict", matching pre-persistence
behaviour for unknown-kind training tables.
training_feature_ranges: Option<Vec<(f64, f64)>>Per-column (min, max) of the training input matrix, parallel to
training_headers. At predict time, inputs are axis-clipped to these
ranges so that out-of-distribution points evaluate at the nearest face
of the training bounding box rather than extrapolating polynomial
trends from polyharmonic / spline bases beyond the data envelope. Old
model JSONs that pre-date this field load with None, in which case
the predict path falls through unchanged (no clipping).
group_metadata: Option<GroupMetadata>User-supplied per-group metadata, keyed by stable group identifier.
This is intentionally schema-free JSON so provenance maps can carry mixed scalar/list/object values. Missing in older payloads means no group metadata was persisted.
deployment_extensions: Vec<SavedDeploymentExtension>Deployment-time no-refit group extensions applied after fitting.
Each entry records the requested group coordinate, caller metadata, and
prior used to initialize the inserted coefficient. The active
prediction contract lives in data_schema + resolved_termspec; this
ledger preserves provenance without requiring a refit.
transformation_response_knots: Option<Vec<f64>>Transformation-normal: B-spline knots for the response-direction basis.
transformation_response_transform: Option<Vec<Vec<f64>>>Transformation-normal: deviation nullspace transform matrix (row-major).
transformation_response_degree: Option<usize>Transformation-normal: B-spline degree for the response basis.
transformation_response_median: Option<f64>Transformation-normal: median of the response used for anchoring.
transformation_score_calibration: Option<TransformationScoreCalibration>Transformation-normal saved score contract. The score is the exact finite-support PIT: z = Phi^{-1}((Phi(h) - Phi(h_L)) / (Phi(h_U) - Phi(h_L))).
resolved_termspec: Option<TermCollectionSpec>§resolved_termspec_noise: Option<TermCollectionSpec>§resolved_termspec_logslope: Option<TermCollectionSpec>§resolved_termspec_logslopes: Option<Vec<TermCollectionSpec>>§adaptive_regularization_diagnostics: Option<AdaptiveRegularizationDiagnostics>§gaussian_jackknife_plus: Option<GaussianJackknifePlusStats>Precomputed exact Gaussian-identity jackknife+ statistics (#942).
Populated only for a standard Gaussian-identity model fit with unit
prior weights, where the closed-form Sherman–Morrison leave-one-out
substrate gives a distribution-free finite-sample (≥ level) prediction
interval with no held-out fold. When Some, predict(interval=level)
auto-routes through it (the MAGIC default); when None — any other
family/link, reweighted rows, or an older payload — predict falls back
to the model-based posterior band and labels the provenance honestly.
#[serde(default)] so pre-existing models deserialize as: no jackknife+
substrate available.
full_conformal: Option<ExactFullConformalSubstrate>Precomputed substrate for the EXACT Gaussian-identity full-conformal set (#942 Layer 1 + the frozen-ρ self-diagnostic).
Populated under the SAME eligibility as gaussian_jackknife_plus
(Gaussian-identity, unit prior weights, offset-free, no link wiggle). It
persists the training design + response + frozen penalty Sλ so the
distribution-free EXACT prediction set (a union of intervals, valid for
any penalized smooth) can be replayed per test point — one Cholesky each,
zero refits — and surfaces the frozen-ρ certificate flag. None for any
ineligible model or an older payload, in which case the exact-set predict
path errors with a clear message and the caller uses jackknife+ or the
posterior band. #[serde(default)] so pre-existing models deserialize as
no exact substrate available.
Implementations§
Source§impl FittedModelPayload
impl FittedModelPayload
pub fn new( version: u32, formula: String, model_kind: ModelKind, family_state: FittedFamily, family: String, ) -> Self
pub fn set_training_feature_metadata( &mut self, headers: Vec<String>, feature_ranges: Vec<(f64, f64)>, )
Sourcepub fn apply_survival_time_basis(&mut self, snapshot: &SavedSurvivalTimeBasis)
pub fn apply_survival_time_basis(&mut self, snapshot: &SavedSurvivalTimeBasis)
Write the persistable time-basis snapshot for a survival model.
This is the only path that should populate the survival_time_*
fields used by the loader. Routing every FFI builder through this
helper guarantees no builder can silently drop a field — the
marginal-slope save→load bug was a builder that
missed survival_time_basis.
Trait Implementations§
Source§impl Clone for FittedModelPayload
impl Clone for FittedModelPayload
Source§fn clone(&self) -> FittedModelPayload
fn clone(&self) -> FittedModelPayload
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de> Deserialize<'de> for FittedModelPayload
impl<'de> Deserialize<'de> for FittedModelPayload
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl !RefUnwindSafe for FittedModelPayload
impl !UnwindSafe for FittedModelPayload
impl Freeze for FittedModelPayload
impl Send for FittedModelPayload
impl Sync for FittedModelPayload
impl Unpin for FittedModelPayload
impl UnsafeUnpin for FittedModelPayload
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.