OpenCV for Unity
2.6.3
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.10.0/index.html ) for the details of the argument of the method.
|
The class implements the Expectation Maximization algorithm. More...
Public Member Functions | |
int | getClustersNumber () |
void | setClustersNumber (int val) |
int | getCovarianceMatrixType () |
void | setCovarianceMatrixType (int val) |
TermCriteria | getTermCriteria () |
void | setTermCriteria (TermCriteria val) |
Mat | getWeights () |
Returns weights of the mixtures. More... | |
Mat | getMeans () |
Returns the cluster centers (means of the Gaussian mixture) More... | |
void | getCovs (List< Mat > covs) |
Returns covariation matrices. More... | |
override float | predict (Mat samples, Mat results, int flags) |
Returns posterior probabilities for the provided samples. More... | |
override float | predict (Mat samples, Mat results) |
Returns posterior probabilities for the provided samples. More... | |
override float | predict (Mat samples) |
Returns posterior probabilities for the provided samples. More... | |
double [] | predict2 (Mat sample, Mat probs) |
Returns a likelihood logarithm value and an index of the most probable mixture component for the given sample. More... | |
bool | trainEM (Mat samples, Mat logLikelihoods, Mat labels, Mat probs) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainEM (Mat samples, Mat logLikelihoods, Mat labels) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainEM (Mat samples, Mat logLikelihoods) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainEM (Mat samples) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainE (Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods, Mat labels, Mat probs) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainE (Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods, Mat labels) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainE (Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainE (Mat samples, Mat means0, Mat covs0, Mat weights0) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainE (Mat samples, Mat means0, Mat covs0) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainE (Mat samples, Mat means0) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainM (Mat samples, Mat probs0, Mat logLikelihoods, Mat labels, Mat probs) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainM (Mat samples, Mat probs0, Mat logLikelihoods, Mat labels) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainM (Mat samples, Mat probs0, Mat logLikelihoods) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
bool | trainM (Mat samples, Mat probs0) |
Estimate the Gaussian mixture parameters from a samples set. More... | |
Public Member Functions inherited from OpenCVForUnity.MlModule.StatModel | |
int | getVarCount () |
Returns the number of variables in training samples. More... | |
override bool | empty () |
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read. More... | |
bool | isTrained () |
Returns true if the model is trained. More... | |
bool | isClassifier () |
Returns true if the model is classifier. More... | |
bool | train (TrainData trainData, int flags) |
Trains the statistical model. More... | |
bool | train (TrainData trainData) |
Trains the statistical model. More... | |
bool | train (Mat samples, int layout, Mat responses) |
Trains the statistical model. More... | |
float | calcError (TrainData data, bool test, Mat resp) |
Computes error on the training or test dataset. More... | |
Public Member Functions inherited from OpenCVForUnity.CoreModule.Algorithm | |
IntPtr | getNativeObjAddr () |
virtual void | clear () |
Clears the algorithm state. More... | |
void | save (string filename) |
virtual string | getDefaultName () |
Public Member Functions inherited from OpenCVForUnity.DisposableObject | |
void | Dispose () |
void | ThrowIfDisposed () |
Static Public Member Functions | |
static new EM | __fromPtr__ (IntPtr addr) |
static EM | create () |
static EM | load (string filepath, string nodeName) |
Loads and creates a serialized EM from a file. More... | |
static EM | load (string filepath) |
Loads and creates a serialized EM from a file. More... | |
Static Public Member Functions inherited from OpenCVForUnity.MlModule.StatModel | |
static new StatModel | __fromPtr__ (IntPtr addr) |
Static Public Member Functions inherited from OpenCVForUnity.CoreModule.Algorithm | |
static Algorithm | __fromPtr__ (IntPtr addr) |
Static Public Member Functions inherited from OpenCVForUnity.DisposableObject | |
static IntPtr | ThrowIfNullIntPtr (IntPtr ptr) |
Public Attributes | |
const int | DEFAULT_NCLUSTERS = 5 |
const int | DEFAULT_MAX_ITERS = 100 |
const int | START_E_STEP = 1 |
const int | START_M_STEP = 2 |
const int | START_AUTO_STEP = 0 |
const int | COV_MAT_SPHERICAL = 0 |
const int | COV_MAT_DIAGONAL = 1 |
const int | COV_MAT_GENERIC = 2 |
const int | COV_MAT_DEFAULT = COV_MAT_DIAGONAL |
Public Attributes inherited from OpenCVForUnity.MlModule.StatModel | |
const int | UPDATE_MODEL = 1 |
const int | RAW_OUTPUT = 1 |
const int | COMPRESSED_INPUT = 2 |
const int | PREPROCESSED_INPUT = 4 |
Protected Member Functions | |
override void | Dispose (bool disposing) |
Protected Member Functions inherited from OpenCVForUnity.MlModule.StatModel | |
override void | Dispose (bool disposing) |
Protected Member Functions inherited from OpenCVForUnity.DisposableOpenCVObject | |
DisposableOpenCVObject () | |
DisposableOpenCVObject (IntPtr ptr) | |
DisposableOpenCVObject (bool isEnabledDispose) | |
DisposableOpenCVObject (IntPtr ptr, bool isEnabledDispose) | |
Protected Member Functions inherited from OpenCVForUnity.DisposableObject | |
DisposableObject () | |
DisposableObject (bool isEnabledDispose) | |
Additional Inherited Members | |
Properties inherited from OpenCVForUnity.DisposableObject | |
bool | IsDisposed [get, protected set] |
bool | IsEnabledDispose [get, set] |
The class implements the Expectation Maximization algorithm.
|
static |
|
static |
|
protectedvirtual |
Reimplemented from OpenCVForUnity.CoreModule.Algorithm.
int OpenCVForUnity.MlModule.EM.getClustersNumber | ( | ) |
int OpenCVForUnity.MlModule.EM.getCovarianceMatrixType | ( | ) |
void OpenCVForUnity.MlModule.EM.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.
Mat OpenCVForUnity.MlModule.EM.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 OpenCVForUnity.MlModule.EM.getTermCriteria | ( | ) |
Mat OpenCVForUnity.MlModule.EM.getWeights | ( | ) |
Returns weights of the mixtures.
Returns vector with the number of elements equal to the number of mixtures.
|
static |
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
filepath | path to serialized EM |
nodeName | name of node containing the classifier |
|
static |
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
filepath | path to serialized EM |
nodeName | name of node containing the classifier |
Returns posterior probabilities for the provided samples.
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 |
Reimplemented from OpenCVForUnity.MlModule.StatModel.
Returns posterior probabilities for the provided samples.
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 |
Reimplemented from OpenCVForUnity.MlModule.StatModel.
|
virtual |
Returns posterior probabilities for the provided samples.
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 |
Reimplemented from OpenCVForUnity.MlModule.StatModel.
Returns a likelihood logarithm value and an index of the most probable mixture component for the given sample.
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.
void OpenCVForUnity.MlModule.EM.setClustersNumber | ( | int | val | ) |
void OpenCVForUnity.MlModule.EM.setCovarianceMatrixType | ( | int | val | ) |
void OpenCVForUnity.MlModule.EM.setTermCriteria | ( | TermCriteria | val | ) |
bool OpenCVForUnity.MlModule.EM.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.
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. |
bool OpenCVForUnity.MlModule.EM.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.
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. |
bool OpenCVForUnity.MlModule.EM.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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
bool OpenCVForUnity.MlModule.EM.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.
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. |
bool OpenCVForUnity.MlModule.EM.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.
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. |
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.
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. |
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.
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. |
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.
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. |
const int OpenCVForUnity.MlModule.EM.COV_MAT_DEFAULT = COV_MAT_DIAGONAL |
const int OpenCVForUnity.MlModule.EM.COV_MAT_DIAGONAL = 1 |
const int OpenCVForUnity.MlModule.EM.COV_MAT_GENERIC = 2 |
const int OpenCVForUnity.MlModule.EM.COV_MAT_SPHERICAL = 0 |
const int OpenCVForUnity.MlModule.EM.DEFAULT_MAX_ITERS = 100 |
const int OpenCVForUnity.MlModule.EM.DEFAULT_NCLUSTERS = 5 |
const int OpenCVForUnity.MlModule.EM.START_AUTO_STEP = 0 |
const int OpenCVForUnity.MlModule.EM.START_E_STEP = 1 |
const int OpenCVForUnity.MlModule.EM.START_M_STEP = 2 |