#[non_exhaustive]pub struct LinearSVR { /* private fields */ }Expand description
Linear Support Vector Regressor.
Uses ε-insensitive loss with L2 penalty, solved by SGD.
Predictions within epsilon of the true value incur no loss.
§Example
use scry_learn::dataset::Dataset;
use scry_learn::svm::LinearSVR;
let features = vec![vec![1.0, 2.0, 3.0, 4.0, 5.0]];
let target = vec![2.0, 4.0, 6.0, 8.0, 10.0];
let data = Dataset::new(features, target, vec!["x".into()], "y");
let mut svr = LinearSVR::new().c(1.0).epsilon(0.1);
svr.fit(&data).unwrap();
let preds = svr.predict(&[vec![3.0]]).unwrap();
assert!((preds[0] - 6.0).abs() < 1.0);Implementations§
Source§impl LinearSVR
impl LinearSVR
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new LinearSVR with default parameters.
Defaults: C = 1.0, epsilon = 0.1, max_iter = 1000, tol = 1e-4.
Sourcepub fn epsilon(self, e: f64) -> Self
pub fn epsilon(self, e: f64) -> Self
Set the epsilon tube width.
Predictions within epsilon of the true value incur zero loss.
Sourcepub fn fit(&mut self, data: &Dataset) -> Result<()>
pub fn fit(&mut self, data: &Dataset) -> Result<()>
Train the SVR on the given dataset.
Auto-dispatches to sparse kernels when the dataset uses sparse storage.
Trait Implementations§
Source§impl PipelineModel for LinearSVR
impl PipelineModel for LinearSVR
Auto Trait Implementations§
impl Freeze for LinearSVR
impl RefUnwindSafe for LinearSVR
impl Send for LinearSVR
impl Sync for LinearSVR
impl Unpin for LinearSVR
impl UnsafeUnpin for LinearSVR
impl UnwindSafe for LinearSVR
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