Expand description
Chain-effect analysis contract + per-dataset score normalization.
Turns a corpus of executed linear pipelines (“chains”, e.g.
SNV → SavGol → PLS), each with a comparable scalar score, into a stable,
serializable ChainEffectAnalysis artifact: every chain projected to a
comparable “goodness” (higher is always better) under a normalization
ChainEffectLens. The authoritative piece that must live natively here
is the per-dataset score normalization (rank / z); downstream consumers such
as nirs4all-ui/chains derive the per-node / position / order aggregates
descriptively from the emitted points.
Boundary: this operates only on stable identifiers, ordered step tokens/roles and scalar scores — never on feature matrices, tensors or fitted operators, consistent with the dag-ml ownership boundary.
Construction is fail-closed: ChainEffectAnalysis::from_observations
rejects empty input, non-finite scores, duplicate ids, mixed evaluation
scopes, and (for the rank/z lenses) any observation missing a dataset
identity. Repeated ordered tokens are preserved verbatim — position and
order are meaningful to downstream consumers.
Deferred (a follow-up slice): building ChainObservations from a
crate::plan::GraphPlan + crate::metrics::ScoreSet. ScoreSet carries
no dataset/source identity (only plan_id); the dataset key must come from
the representation mapping
(crate::data::RepresentationSampleObservationMapping) and the per-variant
node walk needs its own design, so this slice takes host-supplied
observations.
Structs§
- Chain
Effect Analysis - The serialized chain-effect analysis artifact.
- Chain
Effect Metric - The metric the scores are expressed in, plus its optimization direction.
- Chain
Effect Point - One chain projected to a comparable goodness (higher = better).
- Chain
Effect Step - One node occurrence inside a chain.
- Chain
Observation - Host-supplied observation: one executed chain with a comparable score.
Enums§
- Chain
Effect Lens - Normalization lens that makes heterogeneous datasets comparable.
- Chain
Step Role - Coarse role of a chain step; drives color/legend and position/order scoping in downstream consumers.
Constants§
- CHAIN_
EFFECT_ SCHEMA_ ID - Stable
$idof the serialized chain-effect analysis schema. - CHAIN_
EFFECT_ SCHEMA_ VERSION - Current schema version of
ChainEffectAnalysis.
Functions§
- chain_
role_ for_ node_ kind - Map a graph
NodeKindto its coarseChainStepRole. - median
- Median of the finite values (linear interpolation at the midpoint).
- orient
- Orient a score so higher is always better.
- percentile_
ranks - Percentile rank of each value in
[0, 1](1 = largest); average ties. - z_
scores - Sample z-scores (mean 0, unit sd,
n - 1divisor); zero variance → all0.