pub trait RegressionSolver: Sized {
// Required methods
fn create(n_basis: usize) -> Self;
fn add_observation(&mut self, features: &[f64], target: f64);
fn solve(self, lambda: f64) -> Vec<f64>;
fn merge(&mut self, other: Self);
}Expand description
Defines a common interface for solving Linear Least Squares problems: $\min_x ||Ax - b||^2$.
Implementations may vary by:
- Memory Usage: Streaming (low memory) vs Full Matrix (high memory).
- Stability: Normal Equations (unstable) vs QR/SVD (stable).
Required Methods§
Sourcefn create(n_basis: usize) -> Self
fn create(n_basis: usize) -> Self
Creates a new solver instance initialized for n_basis features.
Sourcefn add_observation(&mut self, features: &[f64], target: f64)
fn add_observation(&mut self, features: &[f64], target: f64)
Adds a single observation (row of A, element of b) to the solver.
features: The vector of basis function values $\phi(X)$ (row of design matrix).target: The target value $Y$.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".