View Source Evision.ML.EM (Evision v0.2.9)
Summary
Functions
Computes error on the training or test dataset
Computes error on the training or test dataset
Clears the algorithm state
create
empty
getClustersNumber
getCovarianceMatrixType
Returns covariation matrices
Returns covariation matrices
getDefaultName
Returns the cluster centers (means of the Gaussian mixture)
getTermCriteria
Returns the number of variables in training samples
Returns weights of the mixtures
Returns true if the model is classifier
Returns true if the model is trained
Loads and creates a serialized EM from a file
Loads and creates a serialized EM from a file
Returns a likelihood logarithm value and an index of the most probable mixture component for the given sample.
Returns a likelihood logarithm value and an index of the most probable mixture component for the given sample.
Returns posterior probabilities for the provided samples
Returns posterior probabilities for the provided samples
Reads algorithm parameters from a file storage
save
setClustersNumber
setCovarianceMatrixType
setTermCriteria
Trains the statistical model
Trains the statistical model
Trains the statistical model
Estimate the Gaussian mixture parameters from a samples set.
Estimate the Gaussian mixture parameters from a samples set.
Estimate the Gaussian mixture parameters from a samples set.
Estimate the Gaussian mixture parameters from a samples set.
Estimate the Gaussian mixture parameters from a samples set.
Estimate the Gaussian mixture parameters from a samples set.
Stores algorithm parameters in a file storage
write
Enumerator
Types
Functions
@spec calcError(t(), Evision.ML.TrainData.t(), boolean()) :: {number(), Evision.Mat.t()} | {:error, String.t()}
Computes error on the training or test dataset
Positional Arguments
self:
Evision.ML.EM.t()
data:
Evision.ML.TrainData.t()
.the training data
test:
bool
.if true, the error is computed over the test subset of the data, otherwise it's computed over the training subset of the data. Please note that if you loaded a completely different dataset to evaluate already trained classifier, you will probably want not to set the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so that the error is computed for the whole new set. Yes, this sounds a bit confusing.
Return
retval:
float
resp:
Evision.Mat.t()
.the optional output responses.
The method uses StatModel::predict to compute the error. For regression models the error is computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).
Python prototype (for reference only):
calcError(data, test[, resp]) -> retval, resp
@spec calcError( t(), Evision.ML.TrainData.t(), boolean(), [{atom(), term()}, ...] | nil ) :: {number(), Evision.Mat.t()} | {:error, String.t()}
Computes error on the training or test dataset
Positional Arguments
self:
Evision.ML.EM.t()
data:
Evision.ML.TrainData.t()
.the training data
test:
bool
.if true, the error is computed over the test subset of the data, otherwise it's computed over the training subset of the data. Please note that if you loaded a completely different dataset to evaluate already trained classifier, you will probably want not to set the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so that the error is computed for the whole new set. Yes, this sounds a bit confusing.
Return
retval:
float
resp:
Evision.Mat.t()
.the optional output responses.
The method uses StatModel::predict to compute the error. For regression models the error is computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).
Python prototype (for reference only):
calcError(data, test[, resp]) -> retval, resp
@spec clear(Keyword.t()) :: any() | {:error, String.t()}
@spec clear(t()) :: t() | {:error, String.t()}
Clears the algorithm state
Positional Arguments
- self:
Evision.ML.EM.t()
Python prototype (for reference only):
clear() -> None
create
Return
- retval:
Evision.ML.EM.t()
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).
Python prototype (for reference only):
create() -> retval
@spec empty(Keyword.t()) :: any() | {:error, String.t()}
@spec empty(t()) :: boolean() | {:error, String.t()}
empty
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- retval:
bool
Python prototype (for reference only):
empty() -> retval
@spec getClustersNumber(Keyword.t()) :: any() | {:error, String.t()}
@spec getClustersNumber(t()) :: integer() | {:error, String.t()}
getClustersNumber
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- retval:
integer()
@see setClustersNumber/2
Python prototype (for reference only):
getClustersNumber() -> retval
@spec getCovarianceMatrixType(Keyword.t()) :: any() | {:error, String.t()}
@spec getCovarianceMatrixType(t()) :: integer() | {:error, String.t()}
getCovarianceMatrixType
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- retval:
integer()
@see setCovarianceMatrixType/2
Python prototype (for reference only):
getCovarianceMatrixType() -> retval
@spec getCovs(Keyword.t()) :: any() | {:error, String.t()}
@spec getCovs(t()) :: [Evision.Mat.t()] | {:error, String.t()}
Returns covariation matrices
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- covs:
[Evision.Mat]
.
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.
Python prototype (for reference only):
getCovs([, covs]) -> covs
@spec getCovs(t(), [{atom(), term()}, ...] | nil) :: [Evision.Mat.t()] | {:error, String.t()}
Returns covariation matrices
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- covs:
[Evision.Mat]
.
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.
Python prototype (for reference only):
getCovs([, covs]) -> covs
@spec getDefaultName(Keyword.t()) :: any() | {:error, String.t()}
@spec getDefaultName(t()) :: binary() | {:error, String.t()}
getDefaultName
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- retval:
String
Returns the algorithm string identifier. This string is used as top level xml/yml node tag when the object is saved to a file or string.
Python prototype (for reference only):
getDefaultName() -> retval
@spec getMeans(Keyword.t()) :: any() | {:error, String.t()}
@spec getMeans(t()) :: Evision.Mat.t() | {:error, String.t()}
Returns the cluster centers (means of the Gaussian mixture)
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- retval:
Evision.Mat.t()
Returns matrix with the number of rows equal to the number of mixtures and number of columns equal to the space dimensionality.
Python prototype (for reference only):
getMeans() -> retval
@spec getTermCriteria(Keyword.t()) :: any() | {:error, String.t()}
@spec getTermCriteria(t()) :: {integer(), integer(), number()} | {:error, String.t()}
getTermCriteria
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- retval:
TermCriteria
@see setTermCriteria/2
Python prototype (for reference only):
getTermCriteria() -> retval
@spec getVarCount(Keyword.t()) :: any() | {:error, String.t()}
@spec getVarCount(t()) :: integer() | {:error, String.t()}
Returns the number of variables in training samples
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- retval:
integer()
Python prototype (for reference only):
getVarCount() -> retval
@spec getWeights(Keyword.t()) :: any() | {:error, String.t()}
@spec getWeights(t()) :: Evision.Mat.t() | {:error, String.t()}
Returns weights of the mixtures
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- retval:
Evision.Mat.t()
Returns vector with the number of elements equal to the number of mixtures.
Python prototype (for reference only):
getWeights() -> retval
@spec isClassifier(Keyword.t()) :: any() | {:error, String.t()}
@spec isClassifier(t()) :: boolean() | {:error, String.t()}
Returns true if the model is classifier
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- retval:
bool
Python prototype (for reference only):
isClassifier() -> retval
@spec isTrained(Keyword.t()) :: any() | {:error, String.t()}
@spec isTrained(t()) :: boolean() | {:error, String.t()}
Returns true if the model is trained
Positional Arguments
- self:
Evision.ML.EM.t()
Return
- retval:
bool
Python prototype (for reference only):
isTrained() -> retval
@spec load(Keyword.t()) :: any() | {:error, String.t()}
@spec load(binary()) :: t() | {:error, String.t()}
Loads and creates a serialized EM from a file
Positional Arguments
filepath:
String
.path to serialized EM
Keyword Arguments
nodeName:
String
.name of node containing the classifier
Return
- retval:
Evision.ML.EM.t()
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
Python prototype (for reference only):
load(filepath[, nodeName]) -> retval
Loads and creates a serialized EM from a file
Positional Arguments
filepath:
String
.path to serialized EM
Keyword Arguments
nodeName:
String
.name of node containing the classifier
Return
- retval:
Evision.ML.EM.t()
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
Python prototype (for reference only):
load(filepath[, nodeName]) -> retval
@spec predict2(t(), Evision.Mat.maybe_mat_in()) :: {{number(), number()}, Evision.Mat.t()} | {:error, String.t()}
Returns a likelihood logarithm value and an index of the most probable mixture component for the given sample.
Positional Arguments
self:
Evision.ML.EM.t()
sample:
Evision.Mat
.A sample for classification. It should be a one-channel matrix of \f$1 \times dims\f$ or \f$dims \times 1\f$ size.
Return
retval:
Vec2d
probs:
Evision.Mat.t()
.Optional output matrix that contains posterior probabilities of each component given the sample. It has \f$1 \times nclusters\f$ 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.
Python prototype (for reference only):
predict2(sample[, probs]) -> retval, probs
@spec predict2(t(), Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) :: {{number(), number()}, Evision.Mat.t()} | {:error, String.t()}
Returns a likelihood logarithm value and an index of the most probable mixture component for the given sample.
Positional Arguments
self:
Evision.ML.EM.t()
sample:
Evision.Mat
.A sample for classification. It should be a one-channel matrix of \f$1 \times dims\f$ or \f$dims \times 1\f$ size.
Return
retval:
Vec2d
probs:
Evision.Mat.t()
.Optional output matrix that contains posterior probabilities of each component given the sample. It has \f$1 \times nclusters\f$ 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.
Python prototype (for reference only):
predict2(sample[, probs]) -> retval, probs
@spec predict(t(), Evision.Mat.maybe_mat_in()) :: {number(), Evision.Mat.t()} | {:error, String.t()}
Returns posterior probabilities for the provided samples
Positional Arguments
self:
Evision.ML.EM.t()
samples:
Evision.Mat
.The input samples, floating-point matrix
Keyword Arguments
flags:
integer()
.This parameter will be ignored
Return
retval:
float
results:
Evision.Mat.t()
.The optional output \f$ nSamples \times nClusters\f$ matrix of results. It contains posterior probabilities for each sample from the input
Python prototype (for reference only):
predict(samples[, results[, flags]]) -> retval, results
@spec predict(t(), Evision.Mat.maybe_mat_in(), [{:flags, term()}] | nil) :: {number(), Evision.Mat.t()} | {:error, String.t()}
Returns posterior probabilities for the provided samples
Positional Arguments
self:
Evision.ML.EM.t()
samples:
Evision.Mat
.The input samples, floating-point matrix
Keyword Arguments
flags:
integer()
.This parameter will be ignored
Return
retval:
float
results:
Evision.Mat.t()
.The optional output \f$ nSamples \times nClusters\f$ matrix of results. It contains posterior probabilities for each sample from the input
Python prototype (for reference only):
predict(samples[, results[, flags]]) -> retval, results
@spec read(t(), Evision.FileNode.t()) :: t() | {:error, String.t()}
Reads algorithm parameters from a file storage
Positional Arguments
- self:
Evision.ML.EM.t()
- func:
Evision.FileNode
Python prototype (for reference only):
read(fn) -> None
save
Positional Arguments
- self:
Evision.ML.EM.t()
- filename:
String
Saves the algorithm to a file. In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).
Python prototype (for reference only):
save(filename) -> None
setClustersNumber
Positional Arguments
- self:
Evision.ML.EM.t()
- val:
integer()
@see getClustersNumber/1
Python prototype (for reference only):
setClustersNumber(val) -> None
setCovarianceMatrixType
Positional Arguments
- self:
Evision.ML.EM.t()
- val:
integer()
@see getCovarianceMatrixType/1
Python prototype (for reference only):
setCovarianceMatrixType(val) -> None
setTermCriteria
Positional Arguments
- self:
Evision.ML.EM.t()
- val:
TermCriteria
@see getTermCriteria/1
Python prototype (for reference only):
setTermCriteria(val) -> None
@spec train(t(), Evision.ML.TrainData.t()) :: boolean() | {:error, String.t()}
Trains the statistical model
Positional Arguments
self:
Evision.ML.EM.t()
trainData:
Evision.ML.TrainData.t()
.training data that can be loaded from file using TrainData::loadFromCSV or created with TrainData::create.
Keyword Arguments
flags:
integer()
.optional flags, depending on the model. Some of the models can be updated with the new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).
Return
- retval:
bool
Python prototype (for reference only):
train(trainData[, flags]) -> retval
@spec train(t(), Evision.ML.TrainData.t(), [{:flags, term()}] | nil) :: boolean() | {:error, String.t()}
Trains the statistical model
Positional Arguments
self:
Evision.ML.EM.t()
trainData:
Evision.ML.TrainData.t()
.training data that can be loaded from file using TrainData::loadFromCSV or created with TrainData::create.
Keyword Arguments
flags:
integer()
.optional flags, depending on the model. Some of the models can be updated with the new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).
Return
- retval:
bool
Python prototype (for reference only):
train(trainData[, flags]) -> retval
@spec train(t(), Evision.Mat.maybe_mat_in(), integer(), Evision.Mat.maybe_mat_in()) :: boolean() | {:error, String.t()}
Trains the statistical model
Positional Arguments
self:
Evision.ML.EM.t()
samples:
Evision.Mat
.training samples
layout:
integer()
.See ml::SampleTypes.
responses:
Evision.Mat
.vector of responses associated with the training samples.
Return
- retval:
bool
Python prototype (for reference only):
train(samples, layout, responses) -> retval
@spec trainE(t(), Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) :: {Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()} | false | {:error, String.t()}
Estimate the Gaussian mixture parameters from a samples set.
Positional Arguments
self:
Evision.ML.EM.t()
samples:
Evision.Mat
.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:
Evision.Mat
.Initial means \f$a_k\f$ of mixture components. It is a one-channel matrix of \f$nclusters \times dims\f$ 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.
Keyword Arguments
covs0:
Evision.Mat
.The vector of initial covariance matrices \f$S_k\f$ of mixture components. Each of covariance matrices is a one-channel matrix of \f$dims \times dims\f$ 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:
Evision.Mat
.Initial weights \f$\pi_k\f$ of mixture components. It should be a one-channel floating-point matrix with \f$1 \times nclusters\f$ or \f$nclusters \times 1\f$ size.
Return
retval:
bool
logLikelihoods:
Evision.Mat.t()
.The optional output matrix that contains a likelihood logarithm value for each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type.
labels:
Evision.Mat.t()
.The optional output "class label" for each sample: \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type.
probs:
Evision.Mat.t()
.The optional output matrix that contains posterior probabilities of each Gaussian mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and CV_64FC1 type.
This variation starts with Expectation step. You need to provide initial means \f$a\_k\f$ of mixture components. Optionally you can pass initial weights \f$\pi\_k\f$ and covariance matrices \f$S\_k\f$ of mixture components.
Python prototype (for reference only):
trainE(samples, means0[, covs0[, weights0[, logLikelihoods[, labels[, probs]]]]]) -> retval, logLikelihoods, labels, probs
@spec trainE( t(), Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in(), [covs0: term(), weights0: term()] | nil ) :: {Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()} | false | {:error, String.t()}
Estimate the Gaussian mixture parameters from a samples set.
Positional Arguments
self:
Evision.ML.EM.t()
samples:
Evision.Mat
.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:
Evision.Mat
.Initial means \f$a_k\f$ of mixture components. It is a one-channel matrix of \f$nclusters \times dims\f$ 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.
Keyword Arguments
covs0:
Evision.Mat
.The vector of initial covariance matrices \f$S_k\f$ of mixture components. Each of covariance matrices is a one-channel matrix of \f$dims \times dims\f$ 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:
Evision.Mat
.Initial weights \f$\pi_k\f$ of mixture components. It should be a one-channel floating-point matrix with \f$1 \times nclusters\f$ or \f$nclusters \times 1\f$ size.
Return
retval:
bool
logLikelihoods:
Evision.Mat.t()
.The optional output matrix that contains a likelihood logarithm value for each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type.
labels:
Evision.Mat.t()
.The optional output "class label" for each sample: \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type.
probs:
Evision.Mat.t()
.The optional output matrix that contains posterior probabilities of each Gaussian mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and CV_64FC1 type.
This variation starts with Expectation step. You need to provide initial means \f$a\_k\f$ of mixture components. Optionally you can pass initial weights \f$\pi\_k\f$ and covariance matrices \f$S\_k\f$ of mixture components.
Python prototype (for reference only):
trainE(samples, means0[, covs0[, weights0[, logLikelihoods[, labels[, probs]]]]]) -> retval, logLikelihoods, labels, probs
@spec trainEM(t(), Evision.Mat.maybe_mat_in()) :: {Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()} | false | {:error, String.t()}
Estimate the Gaussian mixture parameters from a samples set.
Positional Arguments
self:
Evision.ML.EM.t()
samples:
Evision.Mat
.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.
Return
retval:
bool
logLikelihoods:
Evision.Mat.t()
.The optional output matrix that contains a likelihood logarithm value for each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type.
labels:
Evision.Mat.t()
.The optional output "class label" for each sample: \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type.
probs:
Evision.Mat.t()
.The optional output matrix that contains posterior probabilities of each Gaussian mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and CV_64FC1 type.
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: \f$p\_{i,k}\f$ in probs, \f$a\_k\f$ in means , \f$S\_k\f$ in covs[k], \f$\pi\_k\f$ in weights , and optionally computes the output "class label" for each sample: \f$\texttt{labels}\_i=\texttt{arg max}\_k(p\_{i,k}), i=1..N\f$ (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.
Python prototype (for reference only):
trainEM(samples[, logLikelihoods[, labels[, probs]]]) -> retval, logLikelihoods, labels, probs
@spec trainEM(t(), Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) :: {Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()} | false | {:error, String.t()}
Estimate the Gaussian mixture parameters from a samples set.
Positional Arguments
self:
Evision.ML.EM.t()
samples:
Evision.Mat
.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.
Return
retval:
bool
logLikelihoods:
Evision.Mat.t()
.The optional output matrix that contains a likelihood logarithm value for each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type.
labels:
Evision.Mat.t()
.The optional output "class label" for each sample: \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type.
probs:
Evision.Mat.t()
.The optional output matrix that contains posterior probabilities of each Gaussian mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and CV_64FC1 type.
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: \f$p\_{i,k}\f$ in probs, \f$a\_k\f$ in means , \f$S\_k\f$ in covs[k], \f$\pi\_k\f$ in weights , and optionally computes the output "class label" for each sample: \f$\texttt{labels}\_i=\texttt{arg max}\_k(p\_{i,k}), i=1..N\f$ (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.
Python prototype (for reference only):
trainEM(samples[, logLikelihoods[, labels[, probs]]]) -> retval, logLikelihoods, labels, probs
@spec trainM(t(), Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) :: {Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()} | false | {:error, String.t()}
Estimate the Gaussian mixture parameters from a samples set.
Positional Arguments
self:
Evision.ML.EM.t()
samples:
Evision.Mat
.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:
Evision.Mat
.the probabilities
Return
retval:
bool
logLikelihoods:
Evision.Mat.t()
.The optional output matrix that contains a likelihood logarithm value for each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type.
labels:
Evision.Mat.t()
.The optional output "class label" for each sample: \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type.
probs:
Evision.Mat.t()
.The optional output matrix that contains posterior probabilities of each Gaussian mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and CV_64FC1 type.
This variation starts with Maximization step. You need to provide initial probabilities \f$p\_{i,k}\f$ to use this option.
Python prototype (for reference only):
trainM(samples, probs0[, logLikelihoods[, labels[, probs]]]) -> retval, logLikelihoods, labels, probs
@spec trainM( t(), Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil ) :: {Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()} | false | {:error, String.t()}
Estimate the Gaussian mixture parameters from a samples set.
Positional Arguments
self:
Evision.ML.EM.t()
samples:
Evision.Mat
.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:
Evision.Mat
.the probabilities
Return
retval:
bool
logLikelihoods:
Evision.Mat.t()
.The optional output matrix that contains a likelihood logarithm value for each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type.
labels:
Evision.Mat.t()
.The optional output "class label" for each sample: \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type.
probs:
Evision.Mat.t()
.The optional output matrix that contains posterior probabilities of each Gaussian mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and CV_64FC1 type.
This variation starts with Maximization step. You need to provide initial probabilities \f$p\_{i,k}\f$ to use this option.
Python prototype (for reference only):
trainM(samples, probs0[, logLikelihoods[, labels[, probs]]]) -> retval, logLikelihoods, labels, probs
@spec write(t(), Evision.FileStorage.t()) :: t() | {:error, String.t()}
Stores algorithm parameters in a file storage
Positional Arguments
- self:
Evision.ML.EM.t()
- fs:
Evision.FileStorage
Python prototype (for reference only):
write(fs) -> None
@spec write(t(), Evision.FileStorage.t(), binary()) :: t() | {:error, String.t()}
write
Positional Arguments
- self:
Evision.ML.EM.t()
- fs:
Evision.FileStorage
- name:
String
Has overloading in C++
Python prototype (for reference only):
write(fs, name) -> None