pub struct Feast { /* private fields */ }Expand description
A FEAST feature-extractor model. Build with Feast::new, adapt online with Feast::fit
(repeatable across recordings/epochs), then map events to feature ids with Feast::transform.
Implementations§
Source§impl Feast
impl Feast
Sourcepub fn new(config: FeastConfig) -> Result<Self, FeastError>
pub fn new(config: FeastConfig) -> Result<Self, FeastError>
Builds a model with random unit-hypersphere feature weights and random thresholds in
[0, 1), seeded by config.seed. Fails if any parameter is out of range.
Sourcepub fn from_state(
config: FeastConfig,
weights: Vec<f32>,
thresholds: Vec<f32>,
) -> Result<Self, FeastError>
pub fn from_state( config: FeastConfig, weights: Vec<f32>, thresholds: Vec<f32>, ) -> Result<Self, FeastError>
Rehydrates a model from saved state (used by the Python save/load round-trip). weights
is the flat [bank][feature][dim] array and thresholds the flat [bank][feature] array;
both must match config’s implied sizes.
Sourcepub fn fit(&mut self, stream: &EventStream, epochs: usize) -> f64
pub fn fit(&mut self, stream: &EventStream, epochs: usize) -> f64
Trains the model on stream for epochs passes (each a fresh time surface, weights and
thresholds carried over), adapting weights and thresholds online. Returns the miss rate
of the final epoch — the fraction of in-bounds events that matched no feature, which settles
to a low steady state (a few percent in the paper) as the network converges.
Sourcepub fn transform(&self, stream: &EventStream) -> Vec<i32>
pub fn transform(&self, stream: &EventStream) -> Vec<i32>
Maps each event to the id of its nearest feature (smallest cosine distance), ignoring
thresholds — the paper’s inference rule. Returns one id per input event, aligned to the
stream; events too close to the border to extract a patch get -1. Ids are global:
population b, feature f → b * n_features + f, so per-polarity OFF ids start at
n_features. Does not modify the model.
Sourcepub fn histogram(&self, stream: &EventStream) -> Vec<u32>
pub fn histogram(&self, stream: &EventStream) -> Vec<u32>
Pooled feature-event counts over stream (the classifier input in the paper): a histogram
of length n_features_total counting how many events each feature won under
Self::transform.
Sourcepub fn weights(&self) -> &[f32]
pub fn weights(&self) -> &[f32]
The learned feature weights, flat [bank][feature][dim] (reshape to
(n_features_total, patch, patch) for the per-feature patch images).
Sourcepub fn thresholds(&self) -> &[f32]
pub fn thresholds(&self) -> &[f32]
The current selection thresholds, flat [bank][feature].
Sourcepub fn n_features_total(&self) -> usize
pub fn n_features_total(&self) -> usize
Total feature count across populations (banks * n_features).
pub fn config(&self) -> &FeastConfig
Sourcepub fn missed_rate(&self) -> f64
pub fn missed_rate(&self) -> f64
Miss rate recorded by the most recent Self::fit (0 before any training).