Methods
|
|
__init__
__pdf
__repr__
classify1
classify2
evaluateFitness
getDiagLogLikelihood
getLogLikelihood
setParameters
|
|
__init__
|
__init__ (
self,
k,
means,
covariances,
weights=None,
)
Creates a new Mixture of Gaussians (MoG) Model, containing k Gaussian
clusters in d-dimensional space. Where:
means is a k-by-d matrix containing the means (one per row) of
the k-Gaussian models.
covariances is a set of k d-by-d covariance matrices (i.e. a
k-by-d-by-d matrix) containing the covariances of the
k-Gaussian models.
weights is a 1-by-k matrix of weights, one for each model.
Optional. If not specified, each of the k-Guassian models
will have equal weight. That is, each element of weights will
default to 1 / k.
|
|
__pdf
|
__pdf (
self,
x,
m,
c,
)
|
|
__repr__
|
__repr__ ( self )
|
|
classify1
|
classify1 ( self, data )
|
|
classify2
|
classify2 ( self, data )
|
|
evaluateFitness
|
evaluateFitness ( self, data )
Return the fitness of the model given a paricular set of data.
First attempt to generate the full covariance fitness score, if that
fails, try to generate a diagonal covariance, if that fails, then the
log-likelihood is set to -MAX_FLOAT =~ -1e38.
|
|
getDiagLogLikelihood
|
getDiagLogLikelihood ( self, data )
Returns the log-likelihood of the given data under the current
model using a diagonal covariance matrix. Data is a matrix of
numbers whose dimensionality (number of columns) must agree with
that of the model.
Exceptions
|
|
ValueError, "Data matrix must have d=%d columns." %( self.d )
|
|
|
getLogLikelihood
|
getLogLikelihood ( self, data )
Returns the log-likelihood of the given data under the current
model. Data is a matrix of numbers whose dimensionality (number
of columns) must agree with that of the model.
Exceptions
|
|
ValueError, "Data matrix must have d=%d columns." %( self.d )
|
|
|
setParameters
|
setParameters (
self,
k,
means,
covariances,
weights,
)
Sets the parameters for this model. See class constructor documentation
for more information.
Exceptions
|
|
ValueError, "Covariance matrices are not square."
ValueError, "Means and covariance matrix number of columns do not match."
ValueError, "Means matrix must have k=%d rows." %( k )
ValueError, "There must be k=%d covariance matrices." %( k )
ValueError, "Weights matrix must have k=%d columns." %( k )
|
|
|