@Namespace(value="cv::ml") @Properties(inherit=opencv_ml.class) public class EM extends StatModel
ml_intro_em
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Modifier and Type | Field and Description |
---|---|
static int |
COV_MAT_DEFAULT
enum cv::ml::EM::Types
|
static int |
COV_MAT_DIAGONAL
enum cv::ml::EM::Types
|
static int |
COV_MAT_GENERIC
enum cv::ml::EM::Types
|
static int |
COV_MAT_SPHERICAL
enum cv::ml::EM::Types
|
static int |
DEFAULT_MAX_ITERS
enum cv::ml::EM::
|
static int |
DEFAULT_NCLUSTERS
enum cv::ml::EM::
|
static int |
START_AUTO_STEP
enum cv::ml::EM::
|
static int |
START_E_STEP
enum cv::ml::EM::
|
static int |
START_M_STEP
enum cv::ml::EM::
|
COMPRESSED_INPUT, PREPROCESSED_INPUT, RAW_OUTPUT, UPDATE_MODEL
Constructor and Description |
---|
EM(Pointer p)
Pointer cast constructor.
|
Modifier and Type | Method and Description |
---|---|
static EM |
create()
Creates empty %EM model.
|
int |
getClustersNumber() |
int |
getCovarianceMatrixType() |
void |
getCovs(MatVector covs)
\brief Returns covariation matrices
|
Mat |
getMeans()
\brief Returns the cluster centers (means of the Gaussian mixture)
|
TermCriteria |
getTermCriteria() |
Mat |
getWeights()
\brief Returns weights of the mixtures
|
static EM |
load(BytePointer filepath) |
static EM |
load(BytePointer filepath,
BytePointer nodeName)
\brief 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) |
static EM |
load(String filepath,
String nodeName) |
float |
predict(GpuMat samples) |
float |
predict(GpuMat samples,
GpuMat results,
int flags) |
float |
predict(Mat samples) |
float |
predict(Mat samples,
Mat results,
int flags)
\brief Returns posterior probabilities for the provided samples
|
float |
predict(UMat samples) |
float |
predict(UMat samples,
UMat results,
int flags) |
Point2d |
predict2(GpuMat sample,
GpuMat probs) |
Point2d |
predict2(Mat sample,
Mat probs)
\brief Returns a likelihood logarithm value and an index of the most probable mixture component
for the given sample.
|
Point2d |
predict2(UMat sample,
UMat probs) |
void |
setClustersNumber(int val)
\copybrief getClustersNumber @see getClustersNumber
|
void |
setCovarianceMatrixType(int val)
\copybrief getCovarianceMatrixType @see getCovarianceMatrixType
|
void |
setTermCriteria(TermCriteria val)
\copybrief getTermCriteria @see getTermCriteria
|
boolean |
trainE(GpuMat samples,
GpuMat means0) |
boolean |
trainE(GpuMat samples,
GpuMat means0,
GpuMat covs0,
GpuMat weights0,
GpuMat logLikelihoods,
GpuMat labels,
GpuMat probs) |
boolean |
trainE(Mat samples,
Mat means0) |
boolean |
trainE(Mat samples,
Mat means0,
Mat covs0,
Mat weights0,
Mat logLikelihoods,
Mat labels,
Mat probs)
\brief Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainE(UMat samples,
UMat means0) |
boolean |
trainE(UMat samples,
UMat means0,
UMat covs0,
UMat weights0,
UMat logLikelihoods,
UMat labels,
UMat probs) |
boolean |
trainEM(GpuMat samples) |
boolean |
trainEM(GpuMat samples,
GpuMat logLikelihoods,
GpuMat labels,
GpuMat probs) |
boolean |
trainEM(Mat samples) |
boolean |
trainEM(Mat samples,
Mat logLikelihoods,
Mat labels,
Mat probs)
\brief Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainEM(UMat samples) |
boolean |
trainEM(UMat samples,
UMat logLikelihoods,
UMat labels,
UMat probs) |
boolean |
trainM(GpuMat samples,
GpuMat probs0) |
boolean |
trainM(GpuMat samples,
GpuMat probs0,
GpuMat logLikelihoods,
GpuMat labels,
GpuMat probs) |
boolean |
trainM(Mat samples,
Mat probs0) |
boolean |
trainM(Mat samples,
Mat probs0,
Mat logLikelihoods,
Mat labels,
Mat probs)
\brief Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainM(UMat samples,
UMat probs0) |
boolean |
trainM(UMat samples,
UMat probs0,
UMat logLikelihoods,
UMat labels,
UMat probs) |
calcError, calcError, calcError, empty, getVarCount, isClassifier, isTrained, train, train, train, train, train
loadANN_MLP, loadANN_MLP, loadBoost, loadBoost, loadDTrees, loadDTrees, loadEM, loadEM, loadKNearest, loadKNearest, loadLogisticRegression, loadLogisticRegression, loadNormalBayesClassifier, loadNormalBayesClassifier, loadRTrees, loadRTrees, loadSVM, loadSVM
clear, getDefaultName, position, read, save, save, write, write, write
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zero
public static final int COV_MAT_SPHERICAL
public static final int COV_MAT_DIAGONAL
public static final int COV_MAT_GENERIC
public static final int COV_MAT_DEFAULT
public static final int DEFAULT_NCLUSTERS
public static final int DEFAULT_MAX_ITERS
public static final int START_E_STEP
public static final int START_M_STEP
public static final int START_AUTO_STEP
public EM(Pointer p)
Pointer.Pointer(Pointer)
.public int getClustersNumber()
setClustersNumber
public void setClustersNumber(int val)
public int getCovarianceMatrixType()
setCovarianceMatrixType
public void setCovarianceMatrixType(int val)
@ByVal public TermCriteria getTermCriteria()
setTermCriteria
public void setTermCriteria(@Const @ByRef TermCriteria val)
@ByVal public Mat getWeights()
Returns vector with the number of elements equal to the number of mixtures.
@ByVal public Mat getMeans()
Returns matrix with the number of rows equal to the number of mixtures and number of columns equal to the space dimensionality.
public void getCovs(@ByRef MatVector covs)
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.
public float predict(@ByVal Mat samples, @ByVal(nullValue="cv::OutputArray(cv::noArray())") Mat results, int flags)
public float predict(@ByVal UMat samples, @ByVal(nullValue="cv::OutputArray(cv::noArray())") UMat results, int flags)
public float predict(@ByVal GpuMat samples, @ByVal(nullValue="cv::OutputArray(cv::noArray())") GpuMat results, int flags)
@ByVal @Cast(value="cv::Vec2d*") public Point2d predict2(@ByVal Mat sample, @ByVal Mat probs)
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.
@ByVal @Cast(value="cv::Vec2d*") public Point2d predict2(@ByVal UMat sample, @ByVal UMat probs)
@ByVal @Cast(value="cv::Vec2d*") public Point2d predict2(@ByVal GpuMat sample, @ByVal GpuMat probs)
@Cast(value="bool") public boolean trainEM(@ByVal Mat samples, @ByVal(nullValue="cv::OutputArray(cv::noArray())") Mat logLikelihoods, @ByVal(nullValue="cv::OutputArray(cv::noArray())") Mat labels, @ByVal(nullValue="cv::OutputArray(cv::noArray())") Mat probs)
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.@Cast(value="bool") public boolean trainEM(@ByVal UMat samples, @ByVal(nullValue="cv::OutputArray(cv::noArray())") UMat logLikelihoods, @ByVal(nullValue="cv::OutputArray(cv::noArray())") UMat labels, @ByVal(nullValue="cv::OutputArray(cv::noArray())") UMat probs)
@Cast(value="bool") public boolean trainEM(@ByVal GpuMat samples, @ByVal(nullValue="cv::OutputArray(cv::noArray())") GpuMat logLikelihoods, @ByVal(nullValue="cv::OutputArray(cv::noArray())") GpuMat labels, @ByVal(nullValue="cv::OutputArray(cv::noArray())") GpuMat probs)
@Cast(value="bool") public boolean trainE(@ByVal Mat samples, @ByVal Mat means0, @ByVal(nullValue="cv::InputArray(cv::noArray())") Mat covs0, @ByVal(nullValue="cv::InputArray(cv::noArray())") Mat weights0, @ByVal(nullValue="cv::OutputArray(cv::noArray())") Mat logLikelihoods, @ByVal(nullValue="cv::OutputArray(cv::noArray())") Mat labels, @ByVal(nullValue="cv::OutputArray(cv::noArray())") Mat probs)
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.@Cast(value="bool") public boolean trainE(@ByVal UMat samples, @ByVal UMat means0, @ByVal(nullValue="cv::InputArray(cv::noArray())") UMat covs0, @ByVal(nullValue="cv::InputArray(cv::noArray())") UMat weights0, @ByVal(nullValue="cv::OutputArray(cv::noArray())") UMat logLikelihoods, @ByVal(nullValue="cv::OutputArray(cv::noArray())") UMat labels, @ByVal(nullValue="cv::OutputArray(cv::noArray())") UMat probs)
@Cast(value="bool") public boolean trainE(@ByVal GpuMat samples, @ByVal GpuMat means0, @ByVal(nullValue="cv::InputArray(cv::noArray())") GpuMat covs0, @ByVal(nullValue="cv::InputArray(cv::noArray())") GpuMat weights0, @ByVal(nullValue="cv::OutputArray(cv::noArray())") GpuMat logLikelihoods, @ByVal(nullValue="cv::OutputArray(cv::noArray())") GpuMat labels, @ByVal(nullValue="cv::OutputArray(cv::noArray())") GpuMat probs)
@Cast(value="bool") public boolean trainM(@ByVal Mat samples, @ByVal Mat probs0, @ByVal(nullValue="cv::OutputArray(cv::noArray())") Mat logLikelihoods, @ByVal(nullValue="cv::OutputArray(cv::noArray())") Mat labels, @ByVal(nullValue="cv::OutputArray(cv::noArray())") Mat probs)
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 probabilitieslogLikelihoods
- 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.@Cast(value="bool") public boolean trainM(@ByVal UMat samples, @ByVal UMat probs0, @ByVal(nullValue="cv::OutputArray(cv::noArray())") UMat logLikelihoods, @ByVal(nullValue="cv::OutputArray(cv::noArray())") UMat labels, @ByVal(nullValue="cv::OutputArray(cv::noArray())") UMat probs)
@Cast(value="bool") public boolean trainM(@ByVal GpuMat samples, @ByVal GpuMat probs0, @ByVal(nullValue="cv::OutputArray(cv::noArray())") GpuMat logLikelihoods, @ByVal(nullValue="cv::OutputArray(cv::noArray())") GpuMat labels, @ByVal(nullValue="cv::OutputArray(cv::noArray())") GpuMat probs)
@opencv_core.Ptr public static EM create()
@opencv_core.Ptr public static EM load(@opencv_core.Str BytePointer filepath, @opencv_core.Str BytePointer nodeName)
filepath
- path to serialized EMnodeName
- name of node containing the classifier@opencv_core.Ptr public static EM load(@opencv_core.Str BytePointer filepath)
@opencv_core.Ptr public static EM load(@opencv_core.Str String filepath, @opencv_core.Str String nodeName)
@opencv_core.Ptr public static EM load(@opencv_core.Str String filepath)
Copyright © 2020. All rights reserved.