MixtureFactory¶
- class otmixmod.MixtureFactory(*args)¶
Mixture inference.
- Parameters:
- atomsNumberint
The number of atoms
- covarianceModelstr, optional
The covariance model. Default is ‘Gaussian_pk_Lk_C’ See
GetValidCovarianceModels()
for available models
Notes
Each value of the covarianceModel parameter defines a specific parametrization of the mixture of Gaussians. See (Biernacki et al., 2006) table 1 page 290 for details on these different parametrizations.
References
Biernacki C., Celeux G., Govaert G., Langrognet F., (2006). Model-Based Cluster and Discriminant Analysis with the MIXMOD Software. Computational Statistics and Data Analysis, vol. 51/2, pp. 587-600.
Examples
Estimate the parameters of the mixture of 2 Gaussians.
>>> import openturns as ot >>> import otmixmod
>>> factory = otmixmod.MixtureFactory(2, 'Gaussian_pk_L_Dk_A_Dk') >>> sample = [ ... [1.5, 0.7], ... [0.2, -0.6], ... [2.1, 0.1], ... [1.2, 2.4], ... [2.2, 0.0], ... [-0.9, -2.1], ... [-1.7, -0.3], ... [0.7, 0.4], ... [-1.2, 1.1], ... [-0.5, -1.1], ... ] >>> estimatedDistribution, labels, logLikelihood = factory.build(sample)
Methods
BuildClusters
(Sample data, Indices labels, OT)Partition a given sample into nbClusters according to the given labels.
Available covariance models names accessor.
build
(...)Build the distribution.
buildAsMixture
(MixtureFactory self, ...)Mixture inference.
buildEstimator
(*args)Build the distribution and the parameter distribution.
getAtomsNumber
(MixtureFactory self)Atoms number accessor.
Accessor to the bootstrap size.
getClassName
(MixtureFactory self)Accessor to the object's name.
getCovarianceModel
(MixtureFactory self)getName
()Accessor to the object's name.
hasName
()Test if the object is named.
setAtomsNumber
(MixtureFactory self, OT)Atoms number accessor.
setBootstrapSize
(bootstrapSize)Accessor to the bootstrap size.
setCovarianceModel
(MixtureFactory self, OT)setName
(name)Accessor to the object's name.
setSeed
(MixtureFactory self, OT)Mixmod RNG seed accessor.
- __init__(MixtureFactory self) MixtureFactory ¶
- __init__(MixtureFactory self, OT::UnsignedInteger const atomsNumber, OT::String const covarianceModel="Gaussian_pk_Lk_C") MixtureFactory
- __init__(MixtureFactory self, MixtureFactory other) MixtureFactory
- static BuildClusters(Sample data, Indices labels, OT::UnsignedInteger const nbClusters) SampleCollection ¶
Partition a given sample into nbClusters according to the given labels.
- Parameters:
- data2-d sequence of float
The sample
- labelssequence of int
The index of the class of each point in the sample
- nbClustersint
The number of clusters in the mixture
- Returns:
- clusterssequence of
openturns.Sample
The list of samples corresponding to each class
- clusterssequence of
- static GetValidCovarianceModels() Description ¶
Available covariance models names accessor.
- Returns:
- names
openturns.Description
Valid covariance model names
- names
Examples
>>> import otmixmod >>> otmixmod.MixtureFactory.GetValidCovarianceModels()[:3] [Gaussian_p_L_I,Gaussian_p_Lk_I,Gaussian_p_L_B]
- build(MixtureFactory self, Sample sample) Distribution ¶
- build(MixtureFactory self, Point parameters) Distribution
- build(MixtureFactory self, Sample sample) Distribution
- build(MixtureFactory self) Distribution
Build the distribution.
Available usages:
build()
build(sample)
build(param)
- Parameters:
- sample2-d sequence of float
Data.
- paramsequence of float
The parameters of the distribution.
- Returns:
- dist
Distribution
The estimated distribution.
In the first usage, the default native distribution is built.
- dist
- buildAsMixture(MixtureFactory self, Sample sample) Mixture ¶
Mixture inference.
- Parameters:
- sample
openturns.Sample
Sample
- sample
- Returns:
- mixture
openturns.Mixture
Inferred distribution
- mixture
- buildEstimator(*args)¶
Build the distribution and the parameter distribution.
- Parameters:
- sample2-d sequence of float
Data.
- parameters
DistributionParameters
Optional, the parametrization.
- Returns:
- resDist
DistributionFactoryResult
The results.
- resDist
Notes
According to the way the native parameters of the distribution are estimated, the parameters distribution differs:
Moments method: the asymptotic parameters distribution is normal and estimated by Bootstrap on the initial data;
Maximum likelihood method with a regular model: the asymptotic parameters distribution is normal and its covariance matrix is the inverse Fisher information matrix;
Other methods: the asymptotic parameters distribution is estimated by Bootstrap on the initial data and kernel fitting (see
KernelSmoothing
).
If another set of parameters is specified, the native parameters distribution is first estimated and the new distribution is determined from it:
if the native parameters distribution is normal and the transformation regular at the estimated parameters values: the asymptotic parameters distribution is normal and its covariance matrix determined from the inverse Fisher information matrix of the native parameters and the transformation;
in the other cases, the asymptotic parameters distribution is estimated by Bootstrap on the initial data and kernel fitting.
- getAtomsNumber(MixtureFactory self) OT::UnsignedInteger ¶
Atoms number accessor.
- Returns:
- atomsNumberint
The number of atoms
- getBootstrapSize()¶
Accessor to the bootstrap size.
- Returns:
- sizeint
Size of the bootstrap.
- getClassName(MixtureFactory self) OT::String ¶
Accessor to the object’s name.
- Returns:
- class_namestr
The object class name (object.__class__.__name__).
- getCovarianceModel(MixtureFactory self) OT::String ¶
- getName()¶
Accessor to the object’s name.
- Returns:
- namestr
The name of the object.
- hasName()¶
Test if the object is named.
- Returns:
- hasNamebool
True if the name is not empty.
- setAtomsNumber(MixtureFactory self, OT::UnsignedInteger const & number)¶
Atoms number accessor.
- Parameters:
- atomsNumberint
The number of atoms
- setBootstrapSize(bootstrapSize)¶
Accessor to the bootstrap size.
- Parameters:
- sizeint
The size of the bootstrap.
- setCovarianceModel(MixtureFactory self, OT::String const covarianceModel)¶
- setName(name)¶
Accessor to the object’s name.
- Parameters:
- namestr
The name of the object.
- setSeed(MixtureFactory self, OT::SignedInteger const seed)¶
Mixmod RNG seed accessor.
- Parameters:
- seedint
Seed used to initialize the Mixmod RNG seed before the learning step. A negative seed will randomly initialize the RNG. The default value is 0.