pub struct WindowedKernelMatrix { /* private fields */ }Expand description
Sliding window kernel matrix for bounded-memory streaming.
Maintains only the most recent window_size samples, automatically
removing oldest samples when the window is full.
§Example
use tensorlogic_sklears_kernels::{WindowedKernelMatrix, LinearKernel, Kernel};
let kernel = LinearKernel::new();
let mut windowed = WindowedKernelMatrix::new(Box::new(kernel), 3);
// Add samples (window size = 3)
windowed.add_sample(vec![1.0]).unwrap();
windowed.add_sample(vec![2.0]).unwrap();
windowed.add_sample(vec![3.0]).unwrap();
windowed.add_sample(vec![4.0]).unwrap(); // First sample evicted
assert_eq!(windowed.len(), 3);Implementations§
Source§impl WindowedKernelMatrix
impl WindowedKernelMatrix
Sourcepub fn new(kernel: Box<dyn Kernel>, window_size: usize) -> Self
pub fn new(kernel: Box<dyn Kernel>, window_size: usize) -> Self
Create a new windowed kernel matrix.
Sourcepub fn add_sample(&mut self, sample: Vec<f64>) -> Result<Option<Vec<f64>>>
pub fn add_sample(&mut self, sample: Vec<f64>) -> Result<Option<Vec<f64>>>
Add a sample, evicting oldest if window is full.
Sourcepub fn get_matrix(&self) -> &Vec<Vec<f64>>
pub fn get_matrix(&self) -> &Vec<Vec<f64>>
Get the current kernel matrix.
Sourcepub fn get_samples(&self) -> &VecDeque<Vec<f64>>
pub fn get_samples(&self) -> &VecDeque<Vec<f64>>
Get samples in the window.
Sourcepub fn window_size(&self) -> usize
pub fn window_size(&self) -> usize
Get the window size.
Sourcepub fn stats(&self) -> &OnlineStats
pub fn stats(&self) -> &OnlineStats
Get statistics.
Auto Trait Implementations§
impl Freeze for WindowedKernelMatrix
impl !RefUnwindSafe for WindowedKernelMatrix
impl Send for WindowedKernelMatrix
impl Sync for WindowedKernelMatrix
impl Unpin for WindowedKernelMatrix
impl !UnwindSafe for WindowedKernelMatrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more