Expectation Maximization With Gaussian Mixture Model.
More...
#include <statistics.h>
Inherits npl::Classifier.
|
| ExpMax (size_t rank, size_t k=2) |
| Constructor for k-means class. More...
|
|
void | setk (size_t ngroups) |
| Update the number of groups. Note that this invalidates any current information. More...
|
|
void | updateMeanCovTau (const Ref< const MatrixXd > newmeans, const Ref< const MatrixXd > newcovs, const Ref< const VectorXd > tau) |
| Sets the mean matrix. Each row of the matrix is a ND-mean, where N is the number of columns. More...
|
|
void | updateMeanCovTau (const Ref< const MatrixXd > samples, Ref< MatrixXd > prob) |
| Updates the mean/cov/tau coordinates by using the weighted class estimates (rather than hard classification, like the previous) More...
|
|
double | expectation (const Ref< const MatrixXd > samples, Ref< MatrixXd > prob) |
| Given a matrix of samples (Samples x Dims, sample on each row), apply the classifier to each sample and return a vector of the classes. More...
|
|
Eigen::VectorXi | classify (const Ref< const MatrixXd > samples) |
| Given a matrix of samples (Samples x Dims, sample on each row), apply the classifier to each sample and return a vector of the classes. More...
|
|
size_t | classify (const Ref< const MatrixXd > samples, Ref< VectorXi > oclass) |
| Given a matrix of samples (Samples x Dims, sample on each row), apply the classifier to each sample and return a vector of the classes. More...
|
|
int | update (const Ref< const MatrixXd > samples, bool reinit=false) |
| Updates the classifier with new samples, if reinit is true then no prior information will be used. If reinit is false then any existing information will be left intact. In Kmeans that would mean that the means will be left at their previous state. More...
|
|
const MatrixXd & | getMeans () |
| Returns the current mean matrix. More...
|
|
const MatrixXd & | getCovs () |
| Returns the current mean matrix. More...
|
|
void | compute (const Ref< const MatrixXd > samples) |
| Alias for updateClasses with reinit = true. This will perform a classification scheme on all the input samples. More...
|
|
|
const int | ndim |
| Number of dimensions, must be set at construction. This is the number of columns in input samples. More...
|
|
int | maxit |
| Maximum number of iterations. Set below 0 for infinite. More...
|
|
Expectation Maximization With Gaussian Mixture Model.
Definition at line 833 of file statistics.h.
npl::ExpMax::ExpMax |
( |
size_t |
rank, |
|
|
size_t |
k = 2 |
|
) |
| |
Constructor for k-means class.
- Parameters
-
rank | Number of dimensions in input samples. |
k | Number of groups to classify samples into |
Eigen::VectorXi npl::ExpMax::classify |
( |
const Ref< const MatrixXd > |
samples | ) |
|
|
virtual |
Given a matrix of samples (Samples x Dims, sample on each row), apply the classifier to each sample and return a vector of the classes.
- Parameters
-
samples | Set of samples, 1 per row |
- Returns
- Vector of classes, rows match up with input sample rows
Implements npl::Classifier.
size_t npl::ExpMax::classify |
( |
const Ref< const MatrixXd > |
samples, |
|
|
Ref< VectorXi > |
oclass |
|
) |
| |
|
virtual |
Given a matrix of samples (Samples x Dims, sample on each row), apply the classifier to each sample and return a vector of the classes.
- Parameters
-
samples | Set of samples, 1 per row |
oclass | Output classes. This vector will be resized to have the same number of rows as samples matrix. |
Implements npl::Classifier.
void npl::Classifier::compute |
( |
const Ref< const MatrixXd > |
samples | ) |
|
|
inlineinherited |
Alias for updateClasses with reinit = true. This will perform a classification scheme on all the input samples.
- Parameters
-
samples | Samples, S x D matrix with S is the number of samples and D is the dimensionality. This must match the internal dimension count. |
Definition at line 713 of file statistics.h.
double npl::ExpMax::expectation |
( |
const Ref< const MatrixXd > |
samples, |
|
|
Ref< MatrixXd > |
prob |
|
) |
| |
Given a matrix of samples (Samples x Dims, sample on each row), apply the classifier to each sample and return a vector of the classes.
- Parameters
-
samples | Set of samples, 1 per row |
prob | Class probability of each sample, for each of the potential distributions |
- Returns
- Change in summed likelihood
const MatrixXd& npl::ExpMax::getCovs |
( |
| ) |
|
|
inline |
Returns the current mean matrix.
- Returns
- The current covariance matrix, with each covariance matrix stacked on top of the next.
Definition at line 936 of file statistics.h.
const MatrixXd& npl::ExpMax::getMeans |
( |
| ) |
|
|
inline |
Returns the current mean matrix.
- Returns
- The current mean matrix
Definition at line 928 of file statistics.h.
void npl::ExpMax::setk |
( |
size_t |
ngroups | ) |
|
Update the number of groups. Note that this invalidates any current information.
- Parameters
-
ngroups | Number of groups to classify |
int npl::ExpMax::update |
( |
const Ref< const MatrixXd > |
samples, |
|
|
bool |
reinit = false |
|
) |
| |
|
virtual |
Updates the classifier with new samples, if reinit is true then no prior information will be used. If reinit is false then any existing information will be left intact. In Kmeans that would mean that the means will be left at their previous state.
- Parameters
-
samples | Samples, S x D matrix with S is the number of samples and D is the dimensionality. This must match the internal dimension count. |
reinit | whether to reinitialize the classifier before updating |
return 0 if converged, -1 otherwise
Implements npl::Classifier.
void npl::ExpMax::updateMeanCovTau |
( |
const Ref< const MatrixXd > |
newmeans, |
|
|
const Ref< const MatrixXd > |
newcovs, |
|
|
const Ref< const VectorXd > |
tau |
|
) |
| |
Sets the mean matrix. Each row of the matrix is a ND-mean, where N is the number of columns.
- Parameters
-
newmeans | Matrix with new mean, means are stacked so that each row represents a group mean |
newmeans | Matrix with new coviance matrices. Covariance matrices are stacked so that row ndim*k gets the first element of the k'th covance matrix. |
newcovs | the new covariance matrices to set in the classifier |
tau | the prior probaibilities of each of the mixture gaussians |
void npl::ExpMax::updateMeanCovTau |
( |
const Ref< const MatrixXd > |
samples, |
|
|
Ref< MatrixXd > |
prob |
|
) |
| |
Updates the mean/cov/tau coordinates by using the weighted class estimates (rather than hard classification, like the previous)
- Parameters
-
samples | Matrix of samples, where each row is an ND-sample. |
prob | Probability that each sample is in a given distribution |
bool npl::Classifier::m_valid |
|
protectedinherited |
Whether the classifier has been initialized yet.
Definition at line 732 of file statistics.h.
int npl::Classifier::maxit |
|
inherited |
Maximum number of iterations. Set below 0 for infinite.
Definition at line 727 of file statistics.h.
const int npl::Classifier::ndim |
|
inherited |
Number of dimensions, must be set at construction. This is the number of columns in input samples.
Definition at line 716 of file statistics.h.
The documentation for this class was generated from the following file: