class_docstr: Standard GMM.
  
  this class contains the following members
  k (int): the number of components in the mixture
  dim (int): is the dimension of the data
  prec_type = 'full' (string) is the parameterization
            of the precisions/covariance matrices:
            either 'full' or 'diagonal'.
  means: array of shape (k,dim):
        all the means (mean parameters) of the components
  precisions: array of shape (k,dim,dim):
             the precisions (inverse covariance matrix) of the components
  weights: array of shape(k): weights of the mixture
  
  fixme
  -----
  no copy method
class_docstr_tok: ["Standard","GMM",".","this","class","contains","the","following","members","k","(","int",")",":","the","number","of","components","in","the","mixture","dim","(","int",")",":","is","the","dimension","of","the","data","prec_type","=","'full","'","(","string",")","is","the","parameterization","of","the","precisions\/covariance","matrices",":","either","'full","'","or","'diagonal","'",".","means",":","array","of","shape","(","k",",","dim",")",":","all","the","means","(","mean","parameters",")","of","the","components","precisions",":","array","of","shape","(","k",",","dim",",","dim",")",":","the","precisions","(","inverse","covariance","matrix",")","of","the","components","weights",":","array","of","shape","(","k",")",":","weights","of","the","mixture","fixme","--","--","-","no","copy","method"]
docstr: Estimation of self given x
  
  Parameters
  ----------
  x array of shape (n_samples,dim)
    the data from which the model is estimated
  z = None: array of shape (n_samples)
      a prior labelling of the data to initialize the computation
  niter=100: maximal number of iterations in the estimation process
  delta = 1.e-4: increment of data likelihood at which
        convergence is declared
  ninit=1: number of initialization performed
           to reach a good solution
  verbose=0: verbosity mode
  
  Returns
  -------
  the best model is returned
docstr_tok: ["Estimation","of","self","given","x","Parameters","--","--","--","--","--","x","array","of","shape","(","n_samples",",","dim",")","the","data","from","which","the","model","is","estimated","z","=","None",":","array","of","shape","(","n_samples",")","a","prior","labelling","of","the","data","to","initialize","the","computation","niter=100",":","maximal","number","of","iterations","in","the","estimation","process","delta","=","1.e-4",":","increment","of","data","likelihood","at","which","convergence","is","declared","ninit=1",":","number","of","initialization","performed","to","reach","a","good","solution","verbose=0",":","verbosity","mode","Returns","--","--","--","-","the","best","model","is","returned"]
code: def initialize_and_estimate(
      self, x, z=None, niter=100, delta=1.0e-4, ninit=1, verbose=0
  ):
      """Estimation of self given x
  
      Parameters
      ----------
      x array of shape (n_samples,dim)
        the data from which the model is estimated
      z = None: array of shape (n_samples)
          a prior labelling of the data to initialize the computation
      niter=100: maximal number of iterations in the estimation process
      delta = 1.e-4: increment of data likelihood at which
            convergence is declared
      ninit=1: number of initialization performed
               to reach a good solution
      verbose=0: verbosity mode
  
      Returns
      -------
      the best model is returned
      """
      bestbic = -np.inf
      bestgmm = GMM(self.k, self.dim, self.prec_type)
      bestgmm.initialize(x)
  
      for i in range(ninit):
          # initialization -> Kmeans
          self.initialize(x)
  
          # alternation of E/M step until convergence
          bic = self.estimate(x, niter=niter, delta=delta, verbose=0)
          if bic > bestbic:
              bestbic = bic
              bestgmm.plugin(self.means, self.precisions, self.weights)
  
      return bestgmm
  
imports: import numpy
  from scipy.linalg import eigvalsh
label_desc: Use image node_id 20 for calling the GMM obj's underlying member method code with example usage: obj.initialize_and_estimate(x, z, niter, delta, ninit, verbose) and returns: bestgmm