pub struct ARDRegression<F> {
pub max_iter: usize,
pub tol: F,
pub alpha_1: F,
pub alpha_2: F,
pub lambda_1: F,
pub lambda_2: F,
pub threshold_lambda: F,
pub fit_intercept: bool,
}Expand description
Automatic Relevance Determination Regression.
Bayesian linear regression with per-feature precision priors. Features with high precision (small variance) are pruned, achieving sparsity.
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§max_iter: usizeMaximum number of EM iterations.
tol: FConvergence tolerance on the relative change in alpha/lambda.
alpha_1: FShape hyperparameter for the alpha (noise precision) Gamma prior.
alpha_2: FRate hyperparameter for the alpha (noise precision) Gamma prior.
lambda_1: FShape hyperparameter for the lambda (weight precision) Gamma prior.
lambda_2: FRate hyperparameter for the lambda (weight precision) Gamma prior.
threshold_lambda: FFeatures with lambda_i > threshold_lambda are pruned.
fit_intercept: boolWhether to fit an intercept (bias) term.
Implementations§
Source§impl<F: Float + FromPrimitive> ARDRegression<F>
impl<F: Float + FromPrimitive> ARDRegression<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ARDRegression with default settings.
Defaults: max_iter = 300, tol = 1e-3, alpha_1 = alpha_2 = 1e-6,
lambda_1 = lambda_2 = 1e-6, threshold_lambda = 1e4,
fit_intercept = true.
Sourcepub fn with_max_iter(self, max_iter: usize) -> Self
pub fn with_max_iter(self, max_iter: usize) -> Self
Set the maximum number of iterations.
Sourcepub fn with_alpha_1(self, alpha_1: F) -> Self
pub fn with_alpha_1(self, alpha_1: F) -> Self
Set the alpha shape hyperparameter.
Sourcepub fn with_alpha_2(self, alpha_2: F) -> Self
pub fn with_alpha_2(self, alpha_2: F) -> Self
Set the alpha rate hyperparameter.
Sourcepub fn with_lambda_1(self, lambda_1: F) -> Self
pub fn with_lambda_1(self, lambda_1: F) -> Self
Set the lambda shape hyperparameter.
Sourcepub fn with_lambda_2(self, lambda_2: F) -> Self
pub fn with_lambda_2(self, lambda_2: F) -> Self
Set the lambda rate hyperparameter.
Sourcepub fn with_threshold_lambda(self, threshold_lambda: F) -> Self
pub fn with_threshold_lambda(self, threshold_lambda: F) -> Self
Set the pruning threshold for feature lambda values.
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 ARDRegression<F>
impl<F: Clone> Clone for ARDRegression<F>
Source§fn clone(&self) -> ARDRegression<F>
fn clone(&self) -> ARDRegression<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 ARDRegression<F>
impl<F: Debug> Debug for ARDRegression<F>
Source§impl<F: Float + FromPrimitive> Default for ARDRegression<F>
impl<F: Float + FromPrimitive> Default for ARDRegression<F>
Source§impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for ARDRegression<F>
impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for ARDRegression<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<FittedARDRegression<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<FittedARDRegression<F>, FerroError>
Fit the ARD model via iterative evidence maximization.
§Errors
FerroError::ShapeMismatch— sample count mismatch.FerroError::InsufficientSamples— fewer than 2 samples.FerroError::NumericalInstability— numerical failure in solver.
Source§type Fitted = FittedARDRegression<F>
type Fitted = FittedARDRegression<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Source§impl<F> PipelineEstimator<F> for ARDRegression<F>
impl<F> PipelineEstimator<F> for ARDRegression<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 ARDRegression<F>where
F: Freeze,
impl<F> RefUnwindSafe for ARDRegression<F>where
F: RefUnwindSafe,
impl<F> Send for ARDRegression<F>where
F: Send,
impl<F> Sync for ARDRegression<F>where
F: Sync,
impl<F> Unpin for ARDRegression<F>where
F: Unpin,
impl<F> UnsafeUnpin for ARDRegression<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for ARDRegression<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