pub struct Standardizer {
pub mean: Vec<f64>,
pub std: Vec<f64>,
}Expand description
Per-dimension affine standardization: (x - mean) / std.
Fields§
§mean: Vec<f64>Per-dimension means.
std: Vec<f64>Per-dimension standard deviations (floored to 1.0 where degenerate).
Implementations§
Source§impl Standardizer
impl Standardizer
Sourcepub fn fit(rows: &[Vec<f64>]) -> Self
pub fn fit(rows: &[Vec<f64>]) -> Self
Fit on a reference sample (rows are feature vectors).
Robust against a runaway column, and otherwise exactly the plain
moments. The unrobustified version is what turned one bad row into a
dead coordinate: six cells of 1e30 in fifty stored observations gave
amp_sustain a mean of ~1.2e29 and a σ of ~5.5e29, which standardizes
every real patch in the pool to −0.2 ± 1e-30 — a column with no variance
left in it, that the model can never learn from and the belief line still
prints a contribution for.
Per column: take the plain moments and the moments with the extreme 2%
of each tail pulled in, and use the second only when the first is
more than [RUNAWAY_RATIO] times wider. That threshold, rather than
winsorizing unconditionally, is deliberate and measured — see
[RUNAWAY_RATIO] for what unconditional cost the search. The fault that
produced the row is fixed upstream of here (PatchTree::clamp_domains,
the featurizer’s quarantine, the load-time repair); this is the line
that means the next one costs a coordinate’s precision rather than the
coordinate.
Winsorizing rather than trimming, when it does fire: the rows are not independent draws from a nuisance distribution — they are the patches the player has actually met, and a real extreme patch is evidence about where the pool is. Pulling it in keeps its vote and takes away only its leverage on the units.
Non-finite cells are dropped from the column they appear in rather than poisoning it; a column that is entirely non-finite falls back to the degenerate case (mean 0, σ 1), which standardizes everything to itself and is the honest reading of “no usable evidence on this axis”.
§Panics
Panics if rows is empty or ragged.
Trait Implementations§
Source§impl Clone for Standardizer
impl Clone for Standardizer
Source§fn clone(&self) -> Standardizer
fn clone(&self) -> Standardizer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Standardizer
impl Debug for Standardizer
Source§impl<'de> Deserialize<'de> for Standardizer
impl<'de> Deserialize<'de> for Standardizer
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>,
Source§impl PartialEq for Standardizer
impl PartialEq for Standardizer
Source§fn eq(&self, other: &Standardizer) -> bool
fn eq(&self, other: &Standardizer) -> bool
self and other values to be equal, and is used by ==.