pub struct TastePosterior {
pub cfg: TasteConfig,
pub samples: Vec<TasteSample>,
pub weights: Vec<f64>,
}Expand description
A fitted posterior: thinned MCMC draws, their importance weights, and
summaries. Weights are uniform straight out of a fit and concentrate as
TastePosterior::reweighted folds in observations between fits.
Fields§
§cfg: TasteConfigThe config this posterior was fit under.
samples: Vec<TasteSample>Thinned posterior draws.
weights: Vec<f64>Normalized importance weights, parallel to samples. Empty means
uniform (and is what older persisted posteriors deserialize to).
Implementations§
Source§impl TastePosterior
impl TastePosterior
Sourcepub fn weight(&self, i: usize) -> f64
pub fn weight(&self, i: usize) -> f64
Importance weight of draw i (uniform when no weights are stored).
Sourcepub fn ess(&self) -> f64
pub fn ess(&self) -> f64
Effective sample size of the weighted draws, 1 / Σ wₛ². Equals the
draw count for uniform weights and collapses toward 1 as the weights
concentrate — the trigger for paying for a full MCMC refit.
Sourcepub fn resampled(&self) -> TastePosterior
pub fn resampled(&self) -> TastePosterior
Systematic resampling: draw the weighted set back to a uniformly weighted one of the same size, deterministically.
Importance weights degenerate — after enough updates almost all the
mass sits on one draw, and a “posterior” of one point tells the
acquisition function that it is certain when it is merely exhausted.
Resampling trades that for duplicate draws, which is the honest cost:
the sample is impoverished but still spans the posterior’s support, and
Self::ess on the fresh uniform weights no longer claims more
information than is there. It is a stopgap between full refits, not a
substitute for one; Engine::needs_refit is still the thing to watch.
Deterministic (systematic, offset ½N) rather than multinomial, because every other stochastic step in this engine is seeded and reproducible and this one has no reason not to be.
Sourcepub fn reweighted(&self, feedback: &Feedback, session: usize) -> TastePosterior
pub fn reweighted(&self, feedback: &Feedback, session: usize) -> TastePosterior
Fold one new standardized observation into the weights by sequential
importance sampling: w_s ← w_s · p(y | θ_s), renormalized.
This is what makes each duel respond to the one before it. A full refit costs seconds of MCMC and cannot run per-vote; without this the acquisition function reads a frozen posterior and re-asks the same question until the next refit.
Sourcepub fn aligned(&self) -> TastePosterior
pub fn aligned(&self) -> TastePosterior
Resolve label switching: relabel each sample’s styles to best match a
reference (the last sample, then one refinement pass against the
aligned mean), by total θ cosine similarity. Per-style summaries
(Self::theta_mean etc.) are only meaningful on an aligned
posterior. No-op at K = 1. K is assumed small (≤ 5): alignment is
exhaustive over permutations.
Sourcepub fn theta_mean(&self, style: usize) -> Vec<f64>
pub fn theta_mean(&self, style: usize) -> Vec<f64>
Posterior mean of θ for a style (align first at K > 1).
Sourcepub fn theta_std(&self, style: usize) -> Vec<f64>
pub fn theta_std(&self, style: usize) -> Vec<f64>
Per-dimension posterior std of θ for a style (credible-interval widths for taste instrumentation; align first at K > 1).
Share of the given candidates claimed by each style: for each φ, the posterior probability that style k is its best lens, averaged over candidates. A style with ≈0 share is inactive — the user’s taste has fewer islands than K. Align first at K > 1.
Sourcepub fn utility(&self, phi: &[f64], style: usize) -> (f64, f64)
pub fn utility(&self, phi: &[f64], style: usize) -> (f64, f64)
Posterior mean and std of the per-style utility u_k(φ).
Sourcepub fn utility_mix(&self, phi: &[f64]) -> (f64, f64)
pub fn utility_mix(&self, phi: &[f64]) -> (f64, f64)
Posterior mean and std of the mixture utility (the ranking score).
Sourcepub fn responsibilities(&self, phi: &[f64]) -> Vec<f64>
pub fn responsibilities(&self, phi: &[f64]) -> Vec<f64>
Style responsibilities of a candidate: the posterior probability that each style is its best lens (align first at K > 1).
Sourcepub fn prob_prefers(&self, a: &[f64], b: &[f64]) -> f64
pub fn prob_prefers(&self, a: &[f64], b: &[f64]) -> f64
Posterior probability that candidate a beats candidate b in a duel
(marginalizing θ, weights, and the per-observation lens).
Trait Implementations§
Source§impl Clone for TastePosterior
impl Clone for TastePosterior
Source§fn clone(&self) -> TastePosterior
fn clone(&self) -> TastePosterior
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more