pyclustering.cluster.ema.ema_initializer Class Reference

Provides services for preparing initial means and covariances for Expectation-Maximization algorithm. More...

Public Member Functions

def __init__ (self, sample, amount)
 Constructs EM initializer. More...
 
def initialize (self, init_type=ema_init_type.KMEANS_INITIALIZATION)
 Calculates initial parameters for EM algorithm: means and covariances using specified strategy. More...
 

Detailed Description

Provides services for preparing initial means and covariances for Expectation-Maximization algorithm.

Initialization strategy is defined by enumerator 'ema_init_type': random initialization and kmeans with kmeans++ initialization. Here an example of initialization using kmeans strategy:

from pyclustering.utils import read_sample
from pyclustering.samples.definitions import FAMOUS_SAMPLES
from pyclustering.cluster.ema import ema_initializer
sample = read_sample(FAMOUS_SAMPLES.SAMPLE_OLD_FAITHFUL)
amount_clusters = 2
initial_means, initial_covariance = ema_initializer(sample, amount_clusters).initialize()
print(initial_means)
print(initial_covariance)

Definition at line 102 of file ema.py.

Constructor & Destructor Documentation

◆ __init__()

def pyclustering.cluster.ema.ema_initializer.__init__ (   self,
  sample,
  amount 
)

Constructs EM initializer.

Parameters
[in]sample(list): Data that will be used by the EM algorithm.
[in]amount(uint): Amount of clusters that should be allocated by the EM algorithm.

Definition at line 125 of file ema.py.

Member Function Documentation

◆ initialize()

def pyclustering.cluster.ema.ema_initializer.initialize (   self,
  init_type = ema_init_type.KMEANS_INITIALIZATION 
)

Calculates initial parameters for EM algorithm: means and covariances using specified strategy.

Parameters
[in]init_type(ema_init_type): Strategy for initialization.
Returns
(float|list, float|numpy.array) Initial means and variance (covariance matrix in case multi-dimensional data).

Definition at line 137 of file ema.py.


The documentation for this class was generated from the following file: