Module mixture :: Class ConstrainedMixtureModel
[hide private]
[frames] | no frames]

Class ConstrainedMixtureModel

source code


Class for a mixture model containing the pairwise constrained version of the E-Step

Instance Methods [hide private]
 
__init__(self, G, pi, components, compFix=None, struct=0)
Constructor
source code
 
__copy__(self)
Interface for the copy.copy function
source code
 
EM(self, data, max_iter, delta, prior_positive, prior_negative, previous_posterior, prior_type, normaliziering=False, silent=False, mix_pi=None, mix_posterior=None, tilt=0)
Reestimation of mixture parameters using the EM algorithm.
source code
 
modelInitialization(self, data, prior_positive, prior_negative, prior_type, normaliziering=False, rtype=1)
Perform model initialization given a random assigment of the data to the models.
source code
 
classify(self, data, prior_positive, prior_negative, previous_posterior, prior_type, labels=None, entropy_cutoff=None, silent=0, normaliziering=False)
Classification of input 'data'.
source code
 
EStep(self, data, mix_posterior=None, mix_pi=None, EStepParam=None)
Reestimation of mixture parameters using the EM algorithm.
source code
 
randMaxEM(self, data, nr_runs, nr_steps, delta, prior_positive, prior_negative, prior_type, tilt=0, silent=False)
Performs `nr_runs` normal EM runs with random initial parameters and returns the model which yields the maximum likelihood.
source code

Inherited from MixtureModel: EStep_old, MStep, __eq__, __str__, flatStr, formatData, identifiable, initStructure, isValid, mapEM, merge, minimalStructure, pdf, posteriorTraceback, printClusterEntropy, printStructure, printTraceback, removeComponent, reorderComponents, sample, sampleDataSet, sampleDataSetLabels, sampleSet, sampleSetLabels, structureEM, sufficientStatistics, updateFreeParams, updateStructureGlobal, update_suff_p, validStructure

Method Details [hide private]

__init__(self, G, pi, components, compFix=None, struct=0)
(Constructor)

source code 

Constructor

Parameters:
  • G - number of components
  • pi - mixture weights
  • components - list of ProductDistribution objects, each entry is one component
  • compFix - list of optional flags for fixing components in the reestimation the following values are supported: 1 distribution parameters are fixed, 2 distribution parameters and mixture coefficients are fixed
  • struct - Flag for CSI structure, 0 = no CSI structure, 1 = CSI structure
Overrides: ProbDistribution.__init__
(inherited documentation)

__copy__(self)

source code 

Interface for the copy.copy function

Overrides: ProbDistribution.__copy__
(inherited documentation)

EM(self, data, max_iter, delta, prior_positive, prior_negative, previous_posterior, prior_type, normaliziering=False, silent=False, mix_pi=None, mix_posterior=None, tilt=0)

source code 

Reestimation of mixture parameters using the EM algorithm. This method do some initial checking and call the EM from MixtureModel with the constrained labels E step

Parameters:
  • data - DataSet object
  • max_iter - maximum number of iterations
  • delta - minimal difference in likelihood between two iterations before convergence is assumed.
  • prior_positive - importance parameter for positive constraints
  • prior_negative - importance parameter for negative constraints
  • previous_posterior - matrix containing the posterior of the previous model assigments
  • prior_type - 1 positive constr. 2 negative constr. 3 positive and negative constr.
  • silent - 0/1 flag, toggles verbose output
  • mix_pi - [internal use only] necessary for the reestimation of mixtures as components
  • mix_posterior - [internal use only] necessary for the reestimation of mixtures as components
  • tilt - 0/1 flag, toggles the use of a deterministic annealing in the training
Returns:
tuple of posterior matrix and log-likelihood from the last iteration
Overrides: MixtureModel.EM

modelInitialization(self, data, prior_positive, prior_negative, prior_type, normaliziering=False, rtype=1)

source code 

Perform model initialization given a random assigment of the data to the models.

Parameters:
  • data - DataSet object
  • rtype - type of random assignments. 0 = fuzzy assingment 1 = hard assingment @return posterior assigments
Returns:
posterior assigments
Overrides: MixtureModel.modelInitialization

classify(self, data, prior_positive, prior_negative, previous_posterior, prior_type, labels=None, entropy_cutoff=None, silent=0, normaliziering=False)

source code 

Classification of input 'data'. Assignment to mixture components by maximum likelihood over the component membership posterior. No parameter reestimation.

Parameters:
  • data - DataSet object
  • labels - optional sample IDs
  • prior_positive - importance parameter for positive constraints
  • prior_negative - importance parameter for negative constraints
  • previous_posterior - matrix containing the posterior of the previous model assigments
  • prior_type - 1 positive constr. 2 negative constr. 3 positive and negative constr.
  • entropy_cutoff - entropy threshold for the posterior distribution. Samples which fall above the threshold will remain unassigned
  • silent - 0/1 flag, toggles verbose output
Returns:
list of class labels
Overrides: MixtureModel.classify

EStep(self, data, mix_posterior=None, mix_pi=None, EStepParam=None)

source code 

Reestimation of mixture parameters using the EM algorithm.

Parameters:
  • data - DataSet object
  • mix_pi - [internal use only] necessary for the reestimation of mixtures as components
  • mix_posterior - [internal use only] necessary for the reestimation of mixtures as components
  • EStepParam - additional paramenters for more complex EStep implementations, in this implementaion it is ignored
Returns:
tuple of log likelihood matrices and sum of log-likelihood of components
Overrides: MixtureModel.EStep

randMaxEM(self, data, nr_runs, nr_steps, delta, prior_positive, prior_negative, prior_type, tilt=0, silent=False)

source code 

Performs `nr_runs` normal EM runs with random initial parameters and returns the model which yields the maximum likelihood.

Parameters:
  • data - DataSet object
  • nr_runs - number of repeated random initializations
  • nr_steps - maximum number of steps in each run
  • delta - minimim difference in log-likelihood before convergence
  • tilt - 0/1 flag, toggles the use of a deterministic annealing in the training
  • silent - 0/1 flag, toggles verbose output
Returns:
log-likelihood of winning model
Overrides: MixtureModel.randMaxEM