Struct linfa_linear::IsotonicRegression
source · pub struct IsotonicRegression {}
Expand description
An isotonic regression model.
IsotonicRegression solves an isotonic regression problem using the pool adjacent violators algorithm.
Examples
Here’s an example on how to train an isotonic regression model on
the first feature from the diabetes
dataset.
use linfa::{traits::Fit, traits::Predict, Dataset};
use linfa_linear::IsotonicRegression;
use linfa::prelude::SingleTargetRegression;
let diabetes = linfa_datasets::diabetes();
let dataset = diabetes.feature_iter().next().unwrap(); // get first 1D feature
let model = IsotonicRegression::default().fit(&dataset).unwrap();
let pred = model.predict(&dataset);
let r2 = pred.r2(&dataset).unwrap();
println!("r2 from prediction: {}", r2);
References
Best, M.J., Chakravarti, N. Active set algorithms for isotonic regression; A unifying framework. Mathematical Programming 47, 425–439 (1990).
Implementations§
source§impl IsotonicRegression
impl IsotonicRegression
sourcepub fn new() -> IsotonicRegression
pub fn new() -> IsotonicRegression
Create a default isotonic regression model.
Trait Implementations§
source§impl Clone for IsotonicRegression
impl Clone for IsotonicRegression
source§fn clone(&self) -> IsotonicRegression
fn clone(&self) -> IsotonicRegression
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for IsotonicRegression
impl Debug for IsotonicRegression
source§impl Default for IsotonicRegression
impl Default for IsotonicRegression
source§fn default() -> IsotonicRegression
fn default() -> IsotonicRegression
source§impl<F: Float, D: Data<Elem = F>, T: AsSingleTargets<Elem = F>> Fit<ArrayBase<D, Dim<[usize; 2]>>, T, LinearError<F>> for IsotonicRegression
impl<F: Float, D: Data<Elem = F>, T: AsSingleTargets<Elem = F>> Fit<ArrayBase<D, Dim<[usize; 2]>>, T, LinearError<F>> for IsotonicRegression
source§fn fit(
&self,
dataset: &DatasetBase<ArrayBase<D, Ix2>, T>
) -> Result<Self::Object, F>
fn fit( &self, dataset: &DatasetBase<ArrayBase<D, Ix2>, T> ) -> Result<Self::Object, F>
Fit an isotonic regression model given a feature matrix X
and a target
variable y
.
The feature matrix X
must have shape (n_samples, 1)
The target variable y
must have shape (n_samples)
Returns a FittedIsotonicRegression
object which contains the fitted
parameters and can be used to predict
values of the target variable
for new feature values.
type Object = FittedIsotonicRegression<F>
source§impl PartialEq for IsotonicRegression
impl PartialEq for IsotonicRegression
source§fn eq(&self, other: &IsotonicRegression) -> bool
fn eq(&self, other: &IsotonicRegression) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for IsotonicRegression
impl StructuralEq for IsotonicRegression
impl StructuralPartialEq for IsotonicRegression
Auto Trait Implementations§
impl RefUnwindSafe for IsotonicRegression
impl Send for IsotonicRegression
impl Sync for IsotonicRegression
impl Unpin for IsotonicRegression
impl UnwindSafe for IsotonicRegression
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.