Trait opencv::prelude::KNearest

source ·
pub trait KNearest: KNearestConst + StatModel {
    // Required method
    fn as_raw_mut_KNearest(&mut self) -> *mut c_void;

    // Provided methods
    fn set_default_k(&mut self, val: i32) -> Result<()> { ... }
    fn set_is_classifier(&mut self, val: bool) -> Result<()> { ... }
    fn set_emax(&mut self, val: i32) -> Result<()> { ... }
    fn set_algorithm_type(&mut self, val: i32) -> Result<()> { ... }
}
Expand description

The class implements K-Nearest Neighbors model

See also

[ml_intro_knn]

Required Methods§

Provided Methods§

source

fn set_default_k(&mut self, val: i32) -> Result<()>

Default number of neighbors to use in predict method.

See also

setDefaultK getDefaultK

source

fn set_is_classifier(&mut self, val: bool) -> Result<()>

Whether classification or regression model should be trained.

See also

setIsClassifier getIsClassifier

source

fn set_emax(&mut self, val: i32) -> Result<()>

Parameter for KDTree implementation.

See also

setEmax getEmax

source

fn set_algorithm_type(&mut self, val: i32) -> Result<()>

%Algorithm type, one of KNearest::Types.

See also

setAlgorithmType getAlgorithmType

Implementations§

source§

impl dyn KNearest + '_

source

pub fn create() -> Result<Ptr<dyn KNearest>>

Creates the empty model

The static method creates empty %KNearest classifier. It should be then trained using StatModel::train method.

source

pub fn load(filepath: &str) -> Result<Ptr<dyn KNearest>>

Loads and creates a serialized knearest from a file

Use KNearest::save to serialize and store an KNearest to disk. Load the KNearest from this file again, by calling this function with the path to the file.

Parameters
  • filepath: path to serialized KNearest

Implementors§