1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Generic feature vector trait for EML model inputs.
//!
//! Any struct that can produce a slice of `f64` values can implement
//! [`FeatureVector`] to be used as input to an [`EmlModel`].
/// Trait for types that can produce a fixed-length feature vector
/// suitable as EML model input.
///
/// Implementors should normalize features to roughly [0, 1] for
/// best numerical stability.
///
/// # Example
///
/// ```
/// use eml_core::FeatureVector;
///
/// struct SensorReading {
/// temperature: f64,
/// humidity: f64,
/// pressure: f64,
/// }
///
/// impl FeatureVector for SensorReading {
/// fn as_features(&self) -> Vec<f64> {
/// vec![
/// self.temperature / 100.0, // normalize to ~[0,1]
/// self.humidity / 100.0,
/// self.pressure / 1100.0,
/// ]
/// }
///
/// fn feature_count() -> usize {
/// 3
/// }
/// }
/// ```