pub trait EMTraitConst: StatModelTraitConst {
// Required method
fn as_raw_EM(&self) -> *const c_void;
// Provided methods
fn get_clusters_number(&self) -> Result<i32> { ... }
fn get_covariance_matrix_type(&self) -> Result<i32> { ... }
fn get_term_criteria(&self) -> Result<TermCriteria> { ... }
fn get_weights(&self) -> Result<Mat> { ... }
fn get_means(&self) -> Result<Mat> { ... }
fn get_covs(&self, covs: &mut Vector<Mat>) -> Result<()> { ... }
fn predict(
&self,
samples: &impl ToInputArray,
results: &mut impl ToOutputArray,
flags: i32,
) -> Result<f32> { ... }
fn predict_def(&self, samples: &impl ToInputArray) -> Result<f32> { ... }
fn predict2(
&self,
sample: &impl ToInputArray,
probs: &mut impl ToOutputArray,
) -> Result<Vec2d> { ... }
}
Expand description
Constant methods for crate::ml::EM
Required Methods§
Provided Methods§
Sourcefn get_clusters_number(&self) -> Result<i32>
fn get_clusters_number(&self) -> Result<i32>
The number of mixture components in the Gaussian mixture model. Default value of the parameter is EM::DEFAULT_NCLUSTERS=5. Some of %EM implementation could determine the optimal number of mixtures within a specified value range, but that is not the case in ML yet.
§See also
setClustersNumber
Sourcefn get_covariance_matrix_type(&self) -> Result<i32>
fn get_covariance_matrix_type(&self) -> Result<i32>
Constraint on covariance matrices which defines type of matrices. See EM::Types.
§See also
setCovarianceMatrixType
Sourcefn get_term_criteria(&self) -> Result<TermCriteria>
fn get_term_criteria(&self) -> Result<TermCriteria>
The termination criteria of the %EM algorithm. The %EM algorithm can be terminated by the number of iterations termCrit.maxCount (number of M-steps) or when relative change of likelihood logarithm is less than termCrit.epsilon. Default maximum number of iterations is EM::DEFAULT_MAX_ITERS=100.
§See also
setTermCriteria
Sourcefn get_weights(&self) -> Result<Mat>
fn get_weights(&self) -> Result<Mat>
Returns weights of the mixtures
Returns vector with the number of elements equal to the number of mixtures.
Sourcefn get_means(&self) -> Result<Mat>
fn get_means(&self) -> Result<Mat>
Returns the cluster centers (means of the Gaussian mixture)
Returns matrix with the number of rows equal to the number of mixtures and number of columns equal to the space dimensionality.
Sourcefn get_covs(&self, covs: &mut Vector<Mat>) -> Result<()>
fn get_covs(&self, covs: &mut Vector<Mat>) -> Result<()>
Returns covariation matrices
Returns vector of covariation matrices. Number of matrices is the number of gaussian mixtures, each matrix is a square floating-point matrix NxN, where N is the space dimensionality.
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>
Returns posterior probabilities for the provided samples
§Parameters
- samples: The input samples, floating-point matrix
- results: The optional output
matrix of results. It contains posterior probabilities for each sample from the input
- flags: This parameter will be ignored
§C++ default parameters
- results: noArray()
- flags: 0
Sourcefn predict_def(&self, samples: &impl ToInputArray) -> Result<f32>
fn predict_def(&self, samples: &impl ToInputArray) -> Result<f32>
Returns posterior probabilities for the provided samples
§Parameters
- samples: The input samples, floating-point matrix
- results: The optional output
matrix of results. It contains posterior probabilities for each sample from the input
- flags: This parameter will be ignored
§Note
This alternative version of EMTraitConst::predict function uses the following default values for its arguments:
- results: noArray()
- flags: 0
Sourcefn predict2(
&self,
sample: &impl ToInputArray,
probs: &mut impl ToOutputArray,
) -> Result<Vec2d>
fn predict2( &self, sample: &impl ToInputArray, probs: &mut impl ToOutputArray, ) -> Result<Vec2d>
Returns a likelihood logarithm value and an index of the most probable mixture component for the given sample.
§Parameters
- sample: A sample for classification. It should be a one-channel matrix of
or
size.
- probs: Optional output matrix that contains posterior probabilities of each component
given the sample. It has
size and CV_64FC1 type.
The method returns a two-element double vector. Zero element is a likelihood logarithm value for the sample. First element is an index of the most probable mixture component for the given sample.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.