#[non_exhaustive]pub struct Ridge { /* private fields */ }Expand description
Ridge regression — LinearRegression with L2 regularization.
This is a thin wrapper around LinearRegression that provides a more
discoverable API for users coming from scikit-learn’s Ridge class.
§Example
use scry_learn::linear::Ridge;
let data = Dataset::new(
vec![vec![1.0, 2.0, 3.0, 4.0, 5.0]],
vec![2.0, 4.0, 6.0, 8.0, 10.0],
vec!["x".into()],
"y",
);
let mut model = Ridge::new(1.0);
model.fit(&data).unwrap();Implementations§
Source§impl Ridge
impl Ridge
Sourcepub fn new(alpha: f64) -> Self
pub fn new(alpha: f64) -> Self
Create a new Ridge regression model with the given L2 regularization strength.
Equivalent to LinearRegression::new().alpha(alpha).
Sourcepub fn predict(&self, features: &[Vec<f64>]) -> Result<Vec<f64>>
pub fn predict(&self, features: &[Vec<f64>]) -> Result<Vec<f64>>
Predict target values for the given feature matrix.
Sourcepub fn coefficients(&self) -> &[f64]
pub fn coefficients(&self) -> &[f64]
Get the learned coefficients.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ridge
impl RefUnwindSafe for Ridge
impl Send for Ridge
impl Sync for Ridge
impl Unpin for Ridge
impl UnsafeUnpin for Ridge
impl UnwindSafe for Ridge
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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