[][src]Trait opencv::hub_prelude::StatModel

pub trait StatModel: AlgorithmTrait {
    pub fn as_raw_StatModel(&self) -> *const c_void;
pub fn as_raw_mut_StatModel(&mut self) -> *mut c_void; pub fn get_var_count(&self) -> Result<i32> { ... }
pub fn empty(&self) -> Result<bool> { ... }
pub fn is_trained(&self) -> Result<bool> { ... }
pub fn is_classifier(&self) -> Result<bool> { ... }
pub fn train_with_data(
        &mut self,
        train_data: &Ptr<dyn TrainData>,
        flags: i32
    ) -> Result<bool> { ... }
pub fn train(
        &mut self,
        samples: &dyn ToInputArray,
        layout: i32,
        responses: &dyn ToInputArray
    ) -> Result<bool> { ... }
pub fn calc_error(
        &self,
        data: &Ptr<dyn TrainData>,
        test: bool,
        resp: &mut dyn ToOutputArray
    ) -> Result<f32> { ... }
pub fn predict(
        &self,
        samples: &dyn ToInputArray,
        results: &mut dyn ToOutputArray,
        flags: i32
    ) -> Result<f32> { ... } }

Base class for statistical models in OpenCV ML.

Required methods

Loading content...

Provided methods

pub fn get_var_count(&self) -> Result<i32>[src]

Returns the number of variables in training samples

pub fn empty(&self) -> Result<bool>[src]

pub fn is_trained(&self) -> Result<bool>[src]

Returns true if the model is trained

pub fn is_classifier(&self) -> Result<bool>[src]

Returns true if the model is classifier

pub fn train_with_data(
    &mut self,
    train_data: &Ptr<dyn TrainData>,
    flags: i32
) -> Result<bool>
[src]

Trains the statistical model

Parameters

  • trainData: training data that can be loaded from file using TrainData::loadFromCSV or created with TrainData::create.
  • flags: optional flags, depending on the model. Some of the models can be updated with the new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).

C++ default parameters

  • flags: 0

pub fn train(
    &mut self,
    samples: &dyn ToInputArray,
    layout: i32,
    responses: &dyn ToInputArray
) -> Result<bool>
[src]

Trains the statistical model

Parameters

  • samples: training samples
  • layout: See ml::SampleTypes.
  • responses: vector of responses associated with the training samples.

pub fn calc_error(
    &self,
    data: &Ptr<dyn TrainData>,
    test: bool,
    resp: &mut dyn ToOutputArray
) -> Result<f32>
[src]

Computes error on the training or test dataset

Parameters

  • data: the training data
  • test: if true, the error is computed over the test subset of the data, otherwise it's computed over the training subset of the data. Please note that if you loaded a completely different dataset to evaluate already trained classifier, you will probably want not to set the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so that the error is computed for the whole new set. Yes, this sounds a bit confusing.
  • resp: the optional output responses.

The method uses StatModel::predict to compute the error. For regression models the error is computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).

pub fn predict(
    &self,
    samples: &dyn ToInputArray,
    results: &mut dyn ToOutputArray,
    flags: i32
) -> Result<f32>
[src]

Predicts response(s) for the provided sample(s)

Parameters

  • samples: The input samples, floating-point matrix
  • results: The optional output matrix of results.
  • flags: The optional flags, model-dependent. See cv::ml::StatModel::Flags.

C++ default parameters

  • results: noArray()
  • flags: 0
Loading content...

Implementors

impl StatModel for PtrOfANN_MLP[src]

impl StatModel for PtrOfBoost[src]

impl StatModel for PtrOfDTrees[src]

impl StatModel for PtrOfEM[src]

impl StatModel for PtrOfKNearest[src]

impl StatModel for PtrOfLogisticRegression[src]

impl StatModel for PtrOfNormalBayesClassifier[src]

impl StatModel for PtrOfRTrees[src]

impl StatModel for PtrOfSVM[src]

impl StatModel for PtrOfSVMSGD[src]

Loading content...