pub struct KNNRegressor<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>, D: Distance<Vec<TX>>> { /* private fields */ }
Expand description

K Nearest Neighbors Regressor

Implementations§

source§

impl<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>, D: Distance<Vec<TX>>> KNNRegressor<TX, TY, X, Y, D>

source

pub fn fit( x: &X, y: &Y, parameters: KNNRegressorParameters<TX, D> ) -> Result<KNNRegressor<TX, TY, X, Y, D>, Failed>

Fits KNN regressor to a NxM matrix where N is number of samples and M is number of features.

  • x - training data
  • y - vector with real values
  • parameters - additional parameters like search algorithm and k
source

pub fn predict(&self, x: &X) -> Result<Y, Failed>

Predict the target for the provided data.

  • x - data of shape NxM where N is number of data points to estimate and M is number of features. Returns a vector of size N with estimates.

Trait Implementations§

source§

impl<TX: Debug + Number, TY: Debug + Number, X: Debug + Array2<TX>, Y: Debug + Array1<TY>, D: Debug + Distance<Vec<TX>>> Debug for KNNRegressor<TX, TY, X, Y, D>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>, D: Distance<Vec<TX>>> PartialEq<KNNRegressor<TX, TY, X, Y, D>> for KNNRegressor<TX, TY, X, Y, D>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>, D: Distance<Vec<TX>>> Predictor<X, Y> for KNNRegressor<TX, TY, X, Y, D>

source§

fn predict(&self, x: &X) -> Result<Y, Failed>

Estimate target values from new data. Read more
source§

impl<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>, D: Distance<Vec<TX>>> SupervisedEstimator<X, Y, KNNRegressorParameters<TX, D>> for KNNRegressor<TX, TY, X, Y, D>

source§

fn new() -> Self

Empty constructor, instantiate an empty estimator. Object is dropped as soon as fit() is called. used to pass around the correct fit() implementation. by calling ::fit(). mostly used to be used with model_selection::cross_validate(...)
source§

fn fit( x: &X, y: &Y, parameters: KNNRegressorParameters<TX, D> ) -> Result<Self, Failed>

Fit a model to a training dataset, estimate model’s parameters. Read more

Auto Trait Implementations§

§

impl<TX, TY, X, Y, D> RefUnwindSafe for KNNRegressor<TX, TY, X, Y, D>where D: RefUnwindSafe, TX: RefUnwindSafe, TY: RefUnwindSafe, X: RefUnwindSafe, Y: RefUnwindSafe,

§

impl<TX, TY, X, Y, D> Send for KNNRegressor<TX, TY, X, Y, D>where D: Send, TX: Send, TY: Send, X: Send, Y: Send,

§

impl<TX, TY, X, Y, D> Sync for KNNRegressor<TX, TY, X, Y, D>where D: Sync, TX: Sync, TY: Sync, X: Sync, Y: Sync,

§

impl<TX, TY, X, Y, D> Unpin for KNNRegressor<TX, TY, X, Y, D>where D: Unpin, TX: Unpin, TY: Unpin, X: Unpin, Y: Unpin,

§

impl<TX, TY, X, Y, D> UnwindSafe for KNNRegressor<TX, TY, X, Y, D>where D: UnwindSafe, TX: UnwindSafe, TY: UnwindSafe, X: UnwindSafe, Y: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.