opencv::prelude

Trait StatModelTraitConst

source
pub trait StatModelTraitConst: AlgorithmTraitConst {
    // Required method
    fn as_raw_StatModel(&self) -> *const c_void;

    // Provided methods
    fn get_var_count(&self) -> Result<i32> { ... }
    fn empty(&self) -> Result<bool> { ... }
    fn is_trained(&self) -> Result<bool> { ... }
    fn is_classifier(&self) -> Result<bool> { ... }
    fn calc_error(
        &self,
        data: &Ptr<TrainData>,
        test: bool,
        resp: &mut impl ToOutputArray,
    ) -> Result<f32> { ... }
    fn predict(
        &self,
        samples: &impl ToInputArray,
        results: &mut impl ToOutputArray,
        flags: i32,
    ) -> Result<f32> { ... }
    fn predict_def(&self, samples: &impl ToInputArray) -> Result<f32> { ... }
}
Expand description

Constant methods for crate::ml::StatModel

Required Methods§

Provided Methods§

source

fn get_var_count(&self) -> Result<i32>

Returns the number of variables in training samples

source

fn empty(&self) -> Result<bool>

source

fn is_trained(&self) -> Result<bool>

Returns true if the model is trained

source

fn is_classifier(&self) -> Result<bool>

Returns true if the model is classifier

source

fn calc_error( &self, data: &Ptr<TrainData>, test: bool, resp: &mut impl ToOutputArray, ) -> Result<f32>

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%).

source

fn predict( &self, samples: &impl ToInputArray, results: &mut impl ToOutputArray, flags: i32, ) -> Result<f32>

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
source

fn predict_def(&self, samples: &impl ToInputArray) -> Result<f32>

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.
§Note

This alternative version of StatModelTraitConst::predict function uses the following default values for its arguments:

  • results: noArray()
  • flags: 0

Object Safety§

This trait is not object safe.

Implementors§

source§

impl StatModelTraitConst for BoxedRef<'_, ANN_MLP>

source§

impl StatModelTraitConst for BoxedRef<'_, Boost>

source§

impl StatModelTraitConst for BoxedRef<'_, DTrees>

source§

impl StatModelTraitConst for BoxedRef<'_, EM>

source§

impl StatModelTraitConst for BoxedRef<'_, KNearest>

source§

impl StatModelTraitConst for BoxedRef<'_, LogisticRegression>

source§

impl StatModelTraitConst for BoxedRef<'_, NormalBayesClassifier>

source§

impl StatModelTraitConst for BoxedRef<'_, RTrees>

source§

impl StatModelTraitConst for BoxedRef<'_, SVM>

source§

impl StatModelTraitConst for BoxedRef<'_, SVMSGD>

source§

impl StatModelTraitConst for BoxedRef<'_, StatModel>

source§

impl StatModelTraitConst for BoxedRefMut<'_, ANN_MLP>

source§

impl StatModelTraitConst for BoxedRefMut<'_, Boost>

source§

impl StatModelTraitConst for BoxedRefMut<'_, DTrees>

source§

impl StatModelTraitConst for BoxedRefMut<'_, EM>

source§

impl StatModelTraitConst for BoxedRefMut<'_, KNearest>

source§

impl StatModelTraitConst for BoxedRefMut<'_, LogisticRegression>

source§

impl StatModelTraitConst for BoxedRefMut<'_, NormalBayesClassifier>

source§

impl StatModelTraitConst for BoxedRefMut<'_, RTrees>

source§

impl StatModelTraitConst for BoxedRefMut<'_, SVM>

source§

impl StatModelTraitConst for BoxedRefMut<'_, SVMSGD>

source§

impl StatModelTraitConst for BoxedRefMut<'_, StatModel>

source§

impl StatModelTraitConst for Ptr<ANN_MLP>

source§

impl StatModelTraitConst for Ptr<Boost>

source§

impl StatModelTraitConst for Ptr<DTrees>

source§

impl StatModelTraitConst for Ptr<EM>

source§

impl StatModelTraitConst for Ptr<KNearest>

source§

impl StatModelTraitConst for Ptr<LogisticRegression>

source§

impl StatModelTraitConst for Ptr<NormalBayesClassifier>

source§

impl StatModelTraitConst for Ptr<RTrees>

source§

impl StatModelTraitConst for Ptr<SVM>

source§

impl StatModelTraitConst for Ptr<SVMSGD>

source§

impl StatModelTraitConst for Ptr<StatModel>

source§

impl StatModelTraitConst for ANN_MLP

source§

impl StatModelTraitConst for Boost

source§

impl StatModelTraitConst for DTrees

source§

impl StatModelTraitConst for EM

source§

impl StatModelTraitConst for KNearest

source§

impl StatModelTraitConst for LogisticRegression

source§

impl StatModelTraitConst for NormalBayesClassifier

source§

impl StatModelTraitConst for RTrees

source§

impl StatModelTraitConst for SVM

source§

impl StatModelTraitConst for SVMSGD

source§

impl StatModelTraitConst for StatModel