pub struct KNNClassifierParameters<T: Number, D: Distance<Vec<T>>> {
pub distance: D,
pub algorithm: KNNAlgorithmName,
pub weight: KNNWeightFunction,
pub k: usize,
/* private fields */
}
Expand description
KNNClassifier
parameters. Use Default::default()
for default values.
Fields§
§distance: D
a function that defines a distance between each pair of point in training data.
This function should extend Distance
trait.
See Distances
for a list of available functions.
algorithm: KNNAlgorithmName
backend search algorithm. See knn search algorithms
. CoverTree
is default.
weight: KNNWeightFunction
weighting function that is used to calculate estimated class value. Default function is KNNWeightFunction::Uniform
.
k: usize
number of training samples to consider when estimating class for new point. Default value is 3.
Implementations§
source§impl<T: Number, D: Distance<Vec<T>>> KNNClassifierParameters<T, D>
impl<T: Number, D: Distance<Vec<T>>> KNNClassifierParameters<T, D>
sourcepub fn with_k(self, k: usize) -> Self
pub fn with_k(self, k: usize) -> Self
number of training samples to consider when estimating class for new point. Default value is 3.
sourcepub fn with_distance<DD: Distance<Vec<T>>>(
self,
distance: DD
) -> KNNClassifierParameters<T, DD>
pub fn with_distance<DD: Distance<Vec<T>>>( self, distance: DD ) -> KNNClassifierParameters<T, DD>
sourcepub fn with_algorithm(self, algorithm: KNNAlgorithmName) -> Self
pub fn with_algorithm(self, algorithm: KNNAlgorithmName) -> Self
backend search algorithm. See knn search algorithms
. CoverTree
is default.
sourcepub fn with_weight(self, weight: KNNWeightFunction) -> Self
pub fn with_weight(self, weight: KNNWeightFunction) -> Self
weighting function that is used to calculate estimated class value. Default function is KNNWeightFunction::Uniform
.
Trait Implementations§
source§impl<T: Clone + Number, D: Clone + Distance<Vec<T>>> Clone for KNNClassifierParameters<T, D>
impl<T: Clone + Number, D: Clone + Distance<Vec<T>>> Clone for KNNClassifierParameters<T, D>
source§fn clone(&self) -> KNNClassifierParameters<T, D>
fn clone(&self) -> KNNClassifierParameters<T, D>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more