pub trait Observation {
// Required methods
fn features(&self) -> &[f64];
fn target(&self) -> f64;
// Provided method
fn weight(&self) -> f64 { ... }
}Expand description
Trait for anything that can be used as a training observation.
Implementors provide a feature slice and a target value. The optional
weight method defaults to 1.0 for uniform weighting.
This trait enables zero-copy training: callers can pass borrowed slices
directly via SampleRef or tuple impls without allocating.
§Built-in implementations
| Type | Allocates? |
|---|---|
SampleRef<'a> | No – borrows &[f64] |
(&[f64], f64) | No – tuple of slice + target |
(Vec<f64>, f64) | Owns Vec<f64> (requires alloc feature) |