pysatl_mpest.initializers#

Initializers build a starting MixtureModel from a sample and a list of component families.

The package exports the base Initializer, the cluster initializer ClusterInitializer with its role contracts Partitioner, ComponentEstimator and Matcher and the protocol ComponentTable, the errors, the partitioning methods KMeansPartitioner, QuantilePartitioner, RandomCentersPartitioner and SklearnPartitioner, the component estimators MLEComponentEstimator and MomentsComponentEstimator, and the matchers HungarianMatcher and IdentityMatcher. SklearnPartitioner needs scikit-learn, an optional dependency installed with pip install pysatl-mpest[sklearn]; the rest of the package works without it. The wrapper MultiStartInitializer repeats another initializer and keeps the best start, and RefiningInitializer improves a start with a mixture estimator of pysatl_mpest.estimators, the only dependency of the package on the estimators. The facade MultiStartRefiningInitializer combines both: every run of the multistart refines its start with the estimator.


Initializers#

ClusterInitializer

Builds a starting mixture by clustering the sample and estimating one component per cluster.

MultiStartInitializer

Runs another initializer several times and returns the start with the largest log-likelihood.

RefiningInitializer

Refines the start of another initializer with a mixture estimator.

MultiStartRefiningInitializer

Runs several starts refined by an estimator and returns the refinement with the largest log-likelihood.

Abstract Classes#

Initializer

Builds a starting MixtureModel from a sample and component families.

Partitioner

Divides a sample into k clusters while the component parameters are still unknown.

ComponentEstimator

Estimates the free parameters of one component from the points of a cluster.

Matcher

Decides which cluster is assigned to which distribution family.

ComponentTable

Everything a matcher may ask about the components estimated for pairs of a family and a cluster.

Partitioners#

KMeansPartitioner

Partitions a sample by one run of k-means with k-means++ initial centers.

QuantilePartitioner

Divides the sorted sample into consecutive segments with equal numbers of points.

RandomCentersPartitioner

Draws centers from the distinct values of the sample and assigns points to the nearest center.

SklearnPartitioner

Partitions a sample by a scikit-learn clusterer with an n_clusters parameter.

Component Estimators#

MLEComponentEstimator

Estimates the free parameters of a component by closed-form maximum likelihood formulas, without optimization.

MomentsComponentEstimator

Estimates the free parameters of a component by the method of moments, without optimization.

Matchers#

HungarianMatcher

Matches clusters to families by the maximum sum of the pair log-likelihoods.

IdentityMatcher

Assigns every family the cluster with the same index.

Exceptions#

InitializationError

An initializer could not build a starting mixture from this partition of the sample.

ComponentEstimationError

The parameters of a component cannot be estimated from a cluster.