Trait opencv::prelude::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> { ... }
}
Expand description
Constant methods for crate::ml::StatModel
Required Methods§
fn as_raw_StatModel(&self) -> *const c_void
Provided Methods§
sourcefn get_var_count(&self) -> Result<i32>
fn get_var_count(&self) -> Result<i32>
Returns the number of variables in training samples
fn empty(&self) -> Result<bool>
sourcefn is_trained(&self) -> Result<bool>
fn is_trained(&self) -> Result<bool>
Returns true if the model is trained
sourcefn is_classifier(&self) -> Result<bool>
fn is_classifier(&self) -> Result<bool>
Returns true if the model is classifier
sourcefn calc_error(
&self,
data: &Ptr<TrainData>,
test: bool,
resp: &mut impl ToOutputArray
) -> Result<f32>
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%).
sourcefn predict(
&self,
samples: &impl ToInputArray,
results: &mut impl ToOutputArray,
flags: i32
) -> Result<f32>
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