Skip to main content

FittedModelPayload

Struct FittedModelPayload 

Source
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 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

Source

pub fn new( version: u32, formula: String, model_kind: ModelKind, family_state: FittedFamily, family: String, ) -> Self

Source

pub fn set_training_feature_metadata( &mut self, headers: Vec<String>, feature_ranges: Vec<(f64, f64)>, )

Source

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

Source§

fn clone(&self) -> FittedModelPayload

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'de> Deserialize<'de> for FittedModelPayload

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for FittedModelPayload

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V