Expand description
Orthogonal Matching Pursuit (OMP).
This module provides OrthogonalMatchingPursuit, a greedy feature
selection algorithm that iteratively selects the feature most correlated
with the current residual, adds it to a support set, solves OLS on
the support, and updates the residual. The process repeats until the
desired number of non-zero coefficients is reached or the residual
tolerance is met.
§Examples
use ferrolearn_linear::OrthogonalMatchingPursuit;
use ferrolearn_core::{Fit, Predict};
use ndarray::{array, Array1, Array2};
let x = Array2::from_shape_vec((5, 3), vec![
1.0, 0.0, 0.0,
2.0, 0.1, 0.0,
3.0, 0.0, 0.1,
4.0, 0.1, 0.0,
5.0, 0.0, 0.1,
]).unwrap();
let y = array![2.0, 4.0, 6.0, 8.0, 10.0];
let model = OrthogonalMatchingPursuit::<f64>::new().with_n_nonzero_coefs(1);
let fitted = model.fit(&x, &y).unwrap();
let preds = fitted.predict(&x).unwrap();
assert_eq!(preds.len(), 5);Structs§
- FittedOMP
- Fitted Orthogonal Matching Pursuit model.
- Orthogonal
Matching Pursuit - Orthogonal Matching Pursuit.