[−][src]Struct fbleau::estimates::knn::KNNEstimator
Keeps track of the error of a k-NN classifier, with the possibility of changing k and removing training examples.
Fields
errors: Vec<f64>
predictions: Vec<Label>
k_error_count: f64
Methods
impl<D> KNNEstimator<D> where
D: Fn(&ArrayView1<f64>, &ArrayView1<f64>) -> f64 + Send + Sync + Copy,
[src]
D: Fn(&ArrayView1<f64>, &ArrayView1<f64>) -> f64 + Send + Sync + Copy,
pub fn new(
test_x: &ArrayView2<f64>,
test_y: &ArrayView1<Label>,
k: usize,
max_k: usize,
distance: D
) -> KNNEstimator<D>
[src]
test_x: &ArrayView2<f64>,
test_y: &ArrayView1<Label>,
k: usize,
max_k: usize,
distance: D
) -> KNNEstimator<D>
Create a new k-NN estimator.
pub fn from_data(
train_x: &ArrayView2<f64>,
train_y: &ArrayView1<Label>,
test_x: &ArrayView2<f64>,
test_y: &ArrayView1<Label>,
k: usize,
max_k: usize,
distance: D
) -> KNNEstimator<D>
[src]
train_x: &ArrayView2<f64>,
train_y: &ArrayView1<Label>,
test_x: &ArrayView2<f64>,
test_y: &ArrayView1<Label>,
k: usize,
max_k: usize,
distance: D
) -> KNNEstimator<D>
Create a k-NN estimator from training and test set.
pub fn add_example(&mut self, x: &ArrayView1<f64>, y: Label) -> Result<(), ()>
[src]
pub fn get_error(&self) -> f64
[src]
Returns the error for the current k.
pub fn get_error_count(&self) -> usize
[src]
Returns the error count for the current k.
pub fn set_k(&mut self, k: usize) -> Result<(), ()>
[src]
Changes the k for which k-NN predictions are given.
Trait Implementations
impl<D: Debug> Debug for KNNEstimator<D> where
D: Fn(&ArrayView1<f64>, &ArrayView1<f64>) -> f64,
[src]
D: Fn(&ArrayView1<f64>, &ArrayView1<f64>) -> f64,
Auto Trait Implementations
impl<D> Send for KNNEstimator<D> where
D: Send,
D: Send,
impl<D> Sync for KNNEstimator<D> where
D: Sync,
D: Sync,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,