org.opencv.ml

## Class EM

- java.lang.Object
- - org.opencv.core.Algorithm
  - - org.opencv.ml.StatModel
    - - org.opencv.ml.EM

-     public class EM
      extends StatModel

  The class implements the Expectation Maximization algorithm. SEE: REF: ml_intro_em

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `COV_MAT_DEFAULT`
    `static int` | `COV_MAT_DIAGONAL`
    `static int` | `COV_MAT_GENERIC`
    `static int` | `COV_MAT_SPHERICAL`
    `static int` | `DEFAULT_MAX_ITERS`
    `static int` | `DEFAULT_NCLUSTERS`
    `static int` | `START_AUTO_STEP`
    `static int` | `START_E_STEP`
    `static int` | `START_M_STEP`

    - ### Fields inherited from class org.opencv.ml.StatModel

      `COMPRESSED_INPUT, PREPROCESSED_INPUT, RAW_OUTPUT, UPDATE_MODEL`

    - ### Fields inherited from class org.opencv.core.Algorithm

      `nativeObj`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `EM(long addr)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static EM` | `__fromPtr__(long addr)`
    `static EM` | `create()` Creates empty %EM model.
    `protected void` | `finalize()`
    `int` | `getClustersNumber()` SEE: setClustersNumber
    `int` | `getCovarianceMatrixType()` SEE: setCovarianceMatrixType
    `void` | `getCovs(List<Mat> covs)` Returns covariation matrices Returns vector of covariation matrices.
    `Mat` | `getMeans()` 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.
    `TermCriteria` | `getTermCriteria()` SEE: setTermCriteria
    `Mat` | `getWeights()` Returns weights of the mixtures Returns vector with the number of elements equal to the number of mixtures.
    `static EM` | `load(String filepath)` Loads and creates a serialized EM from a file Use EM::save to serialize and store an EM to disk.
    `static EM` | `load(String filepath, String nodeName)` Loads and creates a serialized EM from a file Use EM::save to serialize and store an EM to disk.
    `float` | `predict(Mat samples)` Returns posterior probabilities for the provided samples
    `float` | `predict(Mat samples, Mat results)` Returns posterior probabilities for the provided samples
    `float` | `predict(Mat samples, Mat results, int flags)` Returns posterior probabilities for the provided samples
    `double[]` | `predict2(Mat sample, Mat probs)` Returns a likelihood logarithm value and an index of the most probable mixture component for the given sample.
    `void` | `setClustersNumber(int val)` getClustersNumber SEE: getClustersNumber
    `void` | `setCovarianceMatrixType(int val)` getCovarianceMatrixType SEE: getCovarianceMatrixType
    `void` | `setTermCriteria(TermCriteria val)` getTermCriteria SEE: getTermCriteria
    `boolean` | `trainE(Mat samples, Mat means0)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainE(Mat samples, Mat means0, Mat covs0)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainE(Mat samples, Mat means0, Mat covs0, Mat weights0)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainE(Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainE(Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods, Mat labels)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainE(Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods, Mat labels, Mat probs)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainEM(Mat samples)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainEM(Mat samples, Mat logLikelihoods)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainEM(Mat samples, Mat logLikelihoods, Mat labels)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainEM(Mat samples, Mat logLikelihoods, Mat labels, Mat probs)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainM(Mat samples, Mat probs0)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainM(Mat samples, Mat probs0, Mat logLikelihoods)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainM(Mat samples, Mat probs0, Mat logLikelihoods, Mat labels)` Estimate the Gaussian mixture parameters from a samples set.
    `boolean` | `trainM(Mat samples, Mat probs0, Mat logLikelihoods, Mat labels, Mat probs)` Estimate the Gaussian mixture parameters from a samples set.

    - ### Methods inherited from class org.opencv.ml.StatModel

      `calcError, empty, getVarCount, isClassifier, isTrained, train, train, train`

    - ### Methods inherited from class org.opencv.core.Algorithm

      `clear, getDefaultName, getNativeObjAddr, save`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_NCLUSTERS

          public static final int DEFAULT_NCLUSTERS

      See Also:
        Constant Field Values

    - #### DEFAULT_MAX_ITERS

          public static final int DEFAULT_MAX_ITERS

      See Also:
        Constant Field Values

    - #### START_E_STEP

          public static final int START_E_STEP

      See Also:
        Constant Field Values

    - #### START_M_STEP

          public static final int START_M_STEP

      See Also:
        Constant Field Values

    - #### START_AUTO_STEP

          public static final int START_AUTO_STEP

      See Also:
        Constant Field Values

    - #### COV_MAT_SPHERICAL

          public static final int COV_MAT_SPHERICAL

      See Also:
        Constant Field Values

    - #### COV_MAT_DIAGONAL

          public static final int COV_MAT_DIAGONAL

      See Also:
        Constant Field Values

    - #### COV_MAT_GENERIC

          public static final int COV_MAT_GENERIC

      See Also:
        Constant Field Values

    - #### COV_MAT_DEFAULT

          public static final int COV_MAT_DEFAULT

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### EM

          protected EM(long addr)

  - ### Method Detail

    - #### __fromPtr__

          public static EM __fromPtr__(long addr)

    - #### getMeans

          public Mat getMeans()

      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:
        automatically generated

    - #### getWeights

          public Mat getWeights()

      Returns weights of the mixtures Returns vector with the number of elements equal to the number of mixtures.
      Returns:
        automatically generated

    - #### create

          public static EM create()

      Creates empty %EM model. The model should be trained then using StatModel::train(traindata, flags) method. Alternatively, you can use one of the EM::train\* methods or load it from file using Algorithm::load<EM>(filename).
      Returns:
        automatically generated

    - #### load

          public static EM load(String filepath,
                                String nodeName)

      Loads and creates a serialized EM from a file Use EM::save to serialize and store an EM to disk. Load the EM from this file again, by calling this function with the path to the file. Optionally specify the node for the file containing the classifier
      Parameters:
        `filepath` - path to serialized EM
        `nodeName` - name of node containing the classifier
      Returns:
        automatically generated

    - #### load

          public static EM load(String filepath)

      Loads and creates a serialized EM from a file Use EM::save to serialize and store an EM to disk. Load the EM from this file again, by calling this function with the path to the file. Optionally specify the node for the file containing the classifier
      Parameters:
        `filepath` - path to serialized EM
      Returns:
        automatically generated

    - #### getTermCriteria

          public TermCriteria getTermCriteria()

      SEE: setTermCriteria
      Returns:
        automatically generated

    - #### predict2

          public double[] predict2(Mat sample,
                                   Mat probs)

      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 \(1 \times dims\) or \(dims \times 1\) size.
        `probs` - Optional output matrix that contains posterior probabilities of each component given the sample. It has \(1 \times nclusters\) 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.
      Returns:
        automatically generated

    - #### trainE

          public boolean trainE(Mat samples,
                                Mat means0,
                                Mat covs0,
                                Mat weights0,
                                Mat logLikelihoods,
                                Mat labels,
                                Mat probs)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Expectation step. You need to provide initial means \(a_k\) of mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices \(S_k\) of mixture components.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `means0` - Initial means \(a_k\) of mixture components. It is a one-channel matrix of \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `covs0` - The vector of initial covariance matrices \(S_k\) of mixture components. Each of covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices do not have CV_64F type they will be converted to the inner matrices of such type for the further computing.
        `weights0` - Initial weights \(\pi_k\) of mixture components. It should be a one-channel floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
        `logLikelihoods` - The optional output matrix that contains a likelihood logarithm value for each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
        `labels` - The optional output "class label" for each sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
        `probs` - The optional output matrix that contains posterior probabilities of each Gaussian mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainE

          public boolean trainE(Mat samples,
                                Mat means0,
                                Mat covs0,
                                Mat weights0,
                                Mat logLikelihoods,
                                Mat labels)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Expectation step. You need to provide initial means \(a_k\) of mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices \(S_k\) of mixture components.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `means0` - Initial means \(a_k\) of mixture components. It is a one-channel matrix of \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `covs0` - The vector of initial covariance matrices \(S_k\) of mixture components. Each of covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices do not have CV_64F type they will be converted to the inner matrices of such type for the further computing.
        `weights0` - Initial weights \(\pi_k\) of mixture components. It should be a one-channel floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
        `logLikelihoods` - The optional output matrix that contains a likelihood logarithm value for each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
        `labels` - The optional output "class label" for each sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type. mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainE

          public boolean trainE(Mat samples,
                                Mat means0,
                                Mat covs0,
                                Mat weights0,
                                Mat logLikelihoods)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Expectation step. You need to provide initial means \(a_k\) of mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices \(S_k\) of mixture components.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `means0` - Initial means \(a_k\) of mixture components. It is a one-channel matrix of \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `covs0` - The vector of initial covariance matrices \(S_k\) of mixture components. Each of covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices do not have CV_64F type they will be converted to the inner matrices of such type for the further computing.
        `weights0` - Initial weights \(\pi_k\) of mixture components. It should be a one-channel floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
        `logLikelihoods` - The optional output matrix that contains a likelihood logarithm value for each sample. It has \(nsamples \times 1\) size and CV_64FC1 type. \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type. mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainE

          public boolean trainE(Mat samples,
                                Mat means0,
                                Mat covs0,
                                Mat weights0)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Expectation step. You need to provide initial means \(a_k\) of mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices \(S_k\) of mixture components.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `means0` - Initial means \(a_k\) of mixture components. It is a one-channel matrix of \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `covs0` - The vector of initial covariance matrices \(S_k\) of mixture components. Each of covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices do not have CV_64F type they will be converted to the inner matrices of such type for the further computing.
        `weights0` - Initial weights \(\pi_k\) of mixture components. It should be a one-channel floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size. each sample. It has \(nsamples \times 1\) size and CV_64FC1 type. \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type. mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainE

          public boolean trainE(Mat samples,
                                Mat means0,
                                Mat covs0)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Expectation step. You need to provide initial means \(a_k\) of mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices \(S_k\) of mixture components.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `means0` - Initial means \(a_k\) of mixture components. It is a one-channel matrix of \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `covs0` - The vector of initial covariance matrices \(S_k\) of mixture components. Each of covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices do not have CV_64F type they will be converted to the inner matrices of such type for the further computing. floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size. each sample. It has \(nsamples \times 1\) size and CV_64FC1 type. \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type. mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainE

          public boolean trainE(Mat samples,
                                Mat means0)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Expectation step. You need to provide initial means \(a_k\) of mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices \(S_k\) of mixture components.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `means0` - Initial means \(a_k\) of mixture components. It is a one-channel matrix of \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing. covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices do not have CV_64F type they will be converted to the inner matrices of such type for the further computing. floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size. each sample. It has \(nsamples \times 1\) size and CV_64FC1 type. \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type. mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainEM

          public boolean trainEM(Mat samples,
                                 Mat logLikelihoods,
                                 Mat labels,
                                 Mat probs)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Expectation step. Initial values of the model parameters will be estimated by the k-means algorithm. Unlike many of the ML models, %EM is an unsupervised learning algorithm and it does not take responses (class labels or function values) as input. Instead, it computes the *Maximum Likelihood Estimate* of the Gaussian mixture parameters from an input sample set, stores all the parameters inside the structure: \(p_{i,k}\) in probs, \(a_k\) in means , \(S_k\) in covs[k], \(\pi_k\) in weights , and optionally computes the output "class label" for each sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). The trained model can be used further for prediction, just like any other classifier. The trained model is similar to the NormalBayesClassifier.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `logLikelihoods` - The optional output matrix that contains a likelihood logarithm value for each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
        `labels` - The optional output "class label" for each sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
        `probs` - The optional output matrix that contains posterior probabilities of each Gaussian mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainEM

          public boolean trainEM(Mat samples,
                                 Mat logLikelihoods,
                                 Mat labels)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Expectation step. Initial values of the model parameters will be estimated by the k-means algorithm. Unlike many of the ML models, %EM is an unsupervised learning algorithm and it does not take responses (class labels or function values) as input. Instead, it computes the *Maximum Likelihood Estimate* of the Gaussian mixture parameters from an input sample set, stores all the parameters inside the structure: \(p_{i,k}\) in probs, \(a_k\) in means , \(S_k\) in covs[k], \(\pi_k\) in weights , and optionally computes the output "class label" for each sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). The trained model can be used further for prediction, just like any other classifier. The trained model is similar to the NormalBayesClassifier.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `logLikelihoods` - The optional output matrix that contains a likelihood logarithm value for each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
        `labels` - The optional output "class label" for each sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type. mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainEM

          public boolean trainEM(Mat samples,
                                 Mat logLikelihoods)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Expectation step. Initial values of the model parameters will be estimated by the k-means algorithm. Unlike many of the ML models, %EM is an unsupervised learning algorithm and it does not take responses (class labels or function values) as input. Instead, it computes the *Maximum Likelihood Estimate* of the Gaussian mixture parameters from an input sample set, stores all the parameters inside the structure: \(p_{i,k}\) in probs, \(a_k\) in means , \(S_k\) in covs[k], \(\pi_k\) in weights , and optionally computes the output "class label" for each sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). The trained model can be used further for prediction, just like any other classifier. The trained model is similar to the NormalBayesClassifier.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `logLikelihoods` - The optional output matrix that contains a likelihood logarithm value for each sample. It has \(nsamples \times 1\) size and CV_64FC1 type. \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type. mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainEM

          public boolean trainEM(Mat samples)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Expectation step. Initial values of the model parameters will be estimated by the k-means algorithm. Unlike many of the ML models, %EM is an unsupervised learning algorithm and it does not take responses (class labels or function values) as input. Instead, it computes the *Maximum Likelihood Estimate* of the Gaussian mixture parameters from an input sample set, stores all the parameters inside the structure: \(p_{i,k}\) in probs, \(a_k\) in means , \(S_k\) in covs[k], \(\pi_k\) in weights , and optionally computes the output "class label" for each sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). The trained model can be used further for prediction, just like any other classifier. The trained model is similar to the NormalBayesClassifier.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing. each sample. It has \(nsamples \times 1\) size and CV_64FC1 type. \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type. mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainM

          public boolean trainM(Mat samples,
                                Mat probs0,
                                Mat logLikelihoods,
                                Mat labels,
                                Mat probs)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Maximization step. You need to provide initial probabilities \(p_{i,k}\) to use this option.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `probs0` - the probabilities
        `logLikelihoods` - The optional output matrix that contains a likelihood logarithm value for each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
        `labels` - The optional output "class label" for each sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
        `probs` - The optional output matrix that contains posterior probabilities of each Gaussian mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainM

          public boolean trainM(Mat samples,
                                Mat probs0,
                                Mat logLikelihoods,
                                Mat labels)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Maximization step. You need to provide initial probabilities \(p_{i,k}\) to use this option.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `probs0` - the probabilities
        `logLikelihoods` - The optional output matrix that contains a likelihood logarithm value for each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
        `labels` - The optional output "class label" for each sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type. mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainM

          public boolean trainM(Mat samples,
                                Mat probs0,
                                Mat logLikelihoods)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Maximization step. You need to provide initial probabilities \(p_{i,k}\) to use this option.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `probs0` - the probabilities
        `logLikelihoods` - The optional output matrix that contains a likelihood logarithm value for each sample. It has \(nsamples \times 1\) size and CV_64FC1 type. \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type. mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### trainM

          public boolean trainM(Mat samples,
                                Mat probs0)

      Estimate the Gaussian mixture parameters from a samples set. This variation starts with Maximization step. You need to provide initial probabilities \(p_{i,k}\) to use this option.
      Parameters:
        `samples` - Samples from which the Gaussian mixture model will be estimated. It should be a one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type it will be converted to the inner matrix of such type for the further computing.
        `probs0` - the probabilities each sample. It has \(nsamples \times 1\) size and CV_64FC1 type. \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type. mixture component given the each sample. It has \(nsamples \times nclusters\) size and CV_64FC1 type.
      Returns:
        automatically generated

    - #### predict

          public float predict(Mat samples,
                               Mat results,
                               int flags)

      Returns posterior probabilities for the provided samples
      Overrides:
        `predict` in class `StatModel`
      Parameters:
        `samples` - The input samples, floating-point matrix
        `results` - The optional output \( nSamples \times nClusters\) matrix of results. It contains posterior probabilities for each sample from the input
        `flags` - This parameter will be ignored
      Returns:
        automatically generated

    - #### predict

          public float predict(Mat samples,
                               Mat results)

      Returns posterior probabilities for the provided samples
      Overrides:
        `predict` in class `StatModel`
      Parameters:
        `samples` - The input samples, floating-point matrix
        `results` - The optional output \( nSamples \times nClusters\) matrix of results. It contains posterior probabilities for each sample from the input
      Returns:
        automatically generated

    - #### predict

          public float predict(Mat samples)

      Returns posterior probabilities for the provided samples
      Overrides:
        `predict` in class `StatModel`
      Parameters:
        `samples` - The input samples, floating-point matrix posterior probabilities for each sample from the input
      Returns:
        automatically generated

    - #### getClustersNumber

          public int getClustersNumber()

      SEE: setClustersNumber
      Returns:
        automatically generated

    - #### getCovarianceMatrixType

          public int getCovarianceMatrixType()

      SEE: setCovarianceMatrixType
      Returns:
        automatically generated

    - #### getCovs

          public void getCovs(List<Mat> covs)

      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.
      Parameters:
        `covs` - automatically generated

    - #### setClustersNumber

          public void setClustersNumber(int val)

      getClustersNumber SEE: getClustersNumber
      Parameters:
        `val` - automatically generated

    - #### setCovarianceMatrixType

          public void setCovarianceMatrixType(int val)

      getCovarianceMatrixType SEE: getCovarianceMatrixType
      Parameters:
        `val` - automatically generated

    - #### setTermCriteria

          public void setTermCriteria(TermCriteria val)

      getTermCriteria SEE: getTermCriteria
      Parameters:
        `val` - automatically generated

    - #### finalize

          protected void finalize()
                           throws Throwable

      Overrides:
        `finalize` in class `StatModel`
      Throws:
        `Throwable`

Generated on Thu Jul 25 2019 21:39:44 UTC / OpenCV 3.4.7