pub trait EMConst: StatModelConst {
    fn as_raw_EM(&self) -> *const c_void;

    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: &dyn ToInputArray,
        results: &mut dyn ToOutputArray,
        flags: i32
    ) -> Result<f32> { ... } fn predict2(
        &self,
        sample: &dyn ToInputArray,
        probs: &mut dyn ToOutputArray
    ) -> Result<Vec2d> { ... } }
Expand description

The class implements the Expectation Maximization algorithm.

See also

@ref ml_intro_em

Required Methods

Provided Methods

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

Constraint on covariance matrices which defines type of matrices. See EM::Types.

See also

setCovarianceMatrixType

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

Returns weights of the mixtures

Returns vector with the number of elements equal to the number of mixtures.

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.

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.

Returns posterior probabilities for the provided samples

Parameters
  • samples: The input samples, floating-point matrix
  • results: The optional output inline formula 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

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 inline formula or inline formula size.
  • probs: Optional output matrix that contains posterior probabilities of each component given the sample. It has inline formula 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.

Implementors