pub struct OrthogonalMatchingPursuit<F> {
pub n_nonzero_coefs: Option<usize>,
pub tol: Option<F>,
pub fit_intercept: bool,
}Expand description
Orthogonal Matching Pursuit.
A greedy sparse approximation algorithm that selects features one at a time. At each iteration it picks the feature most correlated with the residual, adds it to the support, solves OLS on the support set, and re-computes the residual.
Termination is controlled by either n_nonzero_coefs (maximum
support size) or tol (residual norm threshold), whichever is reached
first.
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§n_nonzero_coefs: Option<usize>Maximum number of non-zero coefficients. Defaults to None (use
all features or stop at tol).
tol: Option<F>Residual norm tolerance. If the squared residual norm drops below
this threshold the algorithm terminates. Defaults to None.
fit_intercept: boolWhether to fit an intercept (bias) term.
Implementations§
Source§impl<F: Float> OrthogonalMatchingPursuit<F>
impl<F: Float> OrthogonalMatchingPursuit<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new OrthogonalMatchingPursuit with default settings.
Defaults: n_nonzero_coefs = None, tol = None,
fit_intercept = true.
Sourcepub fn with_n_nonzero_coefs(self, n: usize) -> Self
pub fn with_n_nonzero_coefs(self, n: usize) -> Self
Set the maximum number of non-zero coefficients.
Sourcepub fn with_fit_intercept(self, fit_intercept: bool) -> Self
pub fn with_fit_intercept(self, fit_intercept: bool) -> Self
Set whether to fit an intercept term.
Trait Implementations§
Source§impl<F: Clone> Clone for OrthogonalMatchingPursuit<F>
impl<F: Clone> Clone for OrthogonalMatchingPursuit<F>
Source§fn clone(&self) -> OrthogonalMatchingPursuit<F>
fn clone(&self) -> OrthogonalMatchingPursuit<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug> Debug for OrthogonalMatchingPursuit<F>
impl<F: Debug> Debug for OrthogonalMatchingPursuit<F>
Source§impl<F: Float> Default for OrthogonalMatchingPursuit<F>
impl<F: Float> Default for OrthogonalMatchingPursuit<F>
Source§impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for OrthogonalMatchingPursuit<F>
impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for OrthogonalMatchingPursuit<F>
Source§fn fit(&self, x: &Array2<F>, y: &Array1<F>) -> Result<FittedOMP<F>, FerroError>
fn fit(&self, x: &Array2<F>, y: &Array1<F>) -> Result<FittedOMP<F>, FerroError>
Fit the OMP model.
Greedily selects features by correlation with the residual and solves OLS on the growing support set.
§Errors
FerroError::ShapeMismatch— sample count mismatch.FerroError::InsufficientSamples— zero samples.FerroError::InvalidParameter—n_nonzero_coefsexceeds features, or neithern_nonzero_coefsnortolis set.
Source§type Error = FerroError
type Error = FerroError
fit.Source§impl<F> PipelineEstimator<F> for OrthogonalMatchingPursuit<F>
impl<F> PipelineEstimator<F> for OrthogonalMatchingPursuit<F>
Source§fn fit_pipeline(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<Box<dyn FittedPipelineEstimator<F>>, FerroError>
fn fit_pipeline( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<Box<dyn FittedPipelineEstimator<F>>, FerroError>
Auto Trait Implementations§
impl<F> Freeze for OrthogonalMatchingPursuit<F>where
F: Freeze,
impl<F> RefUnwindSafe for OrthogonalMatchingPursuit<F>where
F: RefUnwindSafe,
impl<F> Send for OrthogonalMatchingPursuit<F>where
F: Send,
impl<F> Sync for OrthogonalMatchingPursuit<F>where
F: Sync,
impl<F> Unpin for OrthogonalMatchingPursuit<F>where
F: Unpin,
impl<F> UnsafeUnpin for OrthogonalMatchingPursuit<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for OrthogonalMatchingPursuit<F>where
F: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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>
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>
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