pub struct BayesianRidge<F> {
pub max_iter: usize,
pub tol: F,
pub alpha_init: F,
pub lambda_init: F,
pub fit_intercept: bool,
}Expand description
Bayesian Ridge Regression with automatic regularization tuning.
Estimates weight precision (lambda) and noise precision (alpha)
iteratively using evidence maximization. The intercept, if requested,
is fit by centering.
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§max_iter: usizeMaximum number of EM (evidence-maximization) iterations.
tol: FConvergence tolerance on the relative change in log-evidence.
alpha_init: FInitial noise precision (alpha). Must be positive.
lambda_init: FInitial weight precision (lambda). Must be positive.
fit_intercept: boolWhether to fit an intercept (bias) term.
Implementations§
Source§impl<F: Float + FromPrimitive> BayesianRidge<F>
impl<F: Float + FromPrimitive> BayesianRidge<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new BayesianRidge with default settings.
Defaults: max_iter = 300, tol = 1e-3, alpha_init = 1.0,
lambda_init = 1.0, 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_init(self, alpha_init: F) -> Self
pub fn with_alpha_init(self, alpha_init: F) -> Self
Set the initial noise precision.
Sourcepub fn with_lambda_init(self, lambda_init: F) -> Self
pub fn with_lambda_init(self, lambda_init: F) -> Self
Set the initial weight precision.
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 BayesianRidge<F>
impl<F: Clone> Clone for BayesianRidge<F>
Source§fn clone(&self) -> BayesianRidge<F>
fn clone(&self) -> BayesianRidge<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 BayesianRidge<F>
impl<F: Debug> Debug for BayesianRidge<F>
Source§impl<F: Float + FromPrimitive> Default for BayesianRidge<F>
impl<F: Float + FromPrimitive> Default for BayesianRidge<F>
Source§impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for BayesianRidge<F>
impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for BayesianRidge<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<FittedBayesianRidge<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<FittedBayesianRidge<F>, FerroError>
Fit the Bayesian Ridge model via evidence maximization (EM).
Iterates over:
- Solve posterior for
wgiven currentalphaandlambda. - Update
alphaandlambdausing the posterior statistics.
§Errors
FerroError::ShapeMismatch— sample count mismatch.FerroError::InvalidParameter— non-positive initial precisions.FerroError::InsufficientSamples— fewer than 2 samples.FerroError::NumericalInstability— numerical failure in solver.
Source§type Fitted = FittedBayesianRidge<F>
type Fitted = FittedBayesianRidge<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Source§impl PipelineEstimator<f64> for BayesianRidge<f64>
impl PipelineEstimator<f64> for BayesianRidge<f64>
Source§fn fit_pipeline(
&self,
x: &Array2<f64>,
y: &Array1<f64>,
) -> Result<Box<dyn FittedPipelineEstimator<f64>>, FerroError>
fn fit_pipeline( &self, x: &Array2<f64>, y: &Array1<f64>, ) -> Result<Box<dyn FittedPipelineEstimator<f64>>, FerroError>
Fit the model and return it as a boxed pipeline estimator.
§Errors
Propagates any FerroError from fit.
Auto Trait Implementations§
impl<F> Freeze for BayesianRidge<F>where
F: Freeze,
impl<F> RefUnwindSafe for BayesianRidge<F>where
F: RefUnwindSafe,
impl<F> Send for BayesianRidge<F>where
F: Send,
impl<F> Sync for BayesianRidge<F>where
F: Sync,
impl<F> Unpin for BayesianRidge<F>where
F: Unpin,
impl<F> UnsafeUnpin for BayesianRidge<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for BayesianRidge<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