pub struct FitSet {
pub rows: Vec<(Feedback, usize)>,
pub absent: Vec<Vec<usize>>,
}Expand description
A log projected onto one feature order and standardized — exactly what the likelihood sees. Derived at fit time from the log plus a standardizer, and never persisted: the log is the source of truth, this is a view of it.
Fields§
§rows: Vec<(Feedback, usize)>Standardized feedback, paired with its session index, in log order.
absent: Vec<Vec<usize>>Coordinate indices imputed in each row, index-parallel to
Self::rows. Empty rows and an empty vector both mean “nothing was
imputed”, which is the common case and the one that costs nothing.
A parallel vector rather than a field on the tuple because rows is
read positionally in a dozen places (tests, the session layer, the
model); widening it would touch all of them to say something only the
likelihood needs.
§Why the likelihood needs it
An absent coordinate is imputed at the standardizer’s mean, which
standardizes to exactly 0 — the honest imputation for “this observation
says nothing about that axis”. For a duel that is the end of it:
both candidates carry the same absence, so the term cancels in
u_a − u_b and the observation is silent about that axis, correctly.
For keep/kill and stars it does not cancel, because there is no
second candidate to cancel against. u(x) is compared to a threshold,
and a coordinate imputed at zero contributes exactly zero to that sum —
so the model reads a patch that might be extreme on the missing axis as
though it were average on it, and takes the resulting comparison at
full confidence. The information is missing; the certainty should be
too, and without this it is not.
Implementations§
Source§impl FitSet
impl FitSet
Sourcepub fn build(log: &ObservationLog, names: &[String], sz: &Standardizer) -> Self
pub fn build(log: &ObservationLog, names: &[String], sz: &Standardizer) -> Self
Project every observation onto names and standardize with sz.
Coordinates the observation does not have are imputed at the standardizer’s mean — which standardizes to exactly 0, i.e. “this observation says nothing about that axis”, the honest imputation for a feature that did not exist when the vote was cast. Observations from a legacy standardized log are re-used as-is (they are already z-scores); they are on a different geometry, so the session layer migrates them to raw values first where it can.
Sourcepub fn as_is(log: &ObservationLog) -> Self
pub fn as_is(log: &ObservationLog) -> Self
Take the log’s vectors as already being on the model’s scale (unit tests and synthetic users work directly in standardized space).
Sourcepub fn n_sessions(&self) -> usize
pub fn n_sessions(&self) -> usize
Number of distinct sessions referenced (max session index + 1).