class_docstr: This class implements Bayesian GMMs
  
  this class contains the following fields
  k: int,
     the number of components in the mixture
  dim: int,
       the dimension of the data
  means: array of shape (k, dim)
         all the means of the components
  precisions: array of shape (k, dim, dim)
              the precisions of the components
  weights: array of shape (k):
           weights of the mixture
  shrinkage: array of shape (k):
             scaling factor of the posterior precisions on the mean
  dof: array of shape (k)
       the degrees of freedom of the components
  prior_means: array of shape (k, dim):
               the prior on the components means
  prior_scale: array of shape (k, dim):
               the prior on the components precisions
  prior_dof: array of shape (k):
              the prior on the dof (should be at least equal to dim)
  prior_shrinkage: array of shape (k):
                   scaling factor of the prior precisions on the mean
  prior_weights: array of shape (k)
                 the prior on the components weights
  shrinkage: array of shape (k):
             scaling factor of the posterior precisions on the mean
  dof : array of shape (k): the posterior dofs
  
  fixme
  -----
  only 'full' precision is supported
class_docstr_tok: ["This","class","implements","Bayesian","GMMs","this","class","contains","the","following","fields","k",":","int",",","the","number","of","components","in","the","mixture","dim",":","int",",","the","dimension","of","the","data","means",":","array","of","shape","(","k",",","dim",")","all","the","means","of","the","components","precisions",":","array","of","shape","(","k",",","dim",",","dim",")","the","precisions","of","the","components","weights",":","array","of","shape","(","k",")",":","weights","of","the","mixture","shrinkage",":","array","of","shape","(","k",")",":","scaling","factor","of","the","posterior","precisions","on","the","mean","dof",":","array","of","shape","(","k",")","the","degrees","of","freedom","of","the","components","prior_means",":","array","of","shape","(","k",",","dim",")",":","the","prior","on","the","components","means","prior_scale",":","array","of","shape","(","k",",","dim",")",":","the","prior","on","the","components","precisions","prior_dof",":","array","of","shape","(","k",")",":","the","prior","on","the","dof","(","should","be","at","least","equal","to","dim",")","prior_shrinkage",":","array","of","shape","(","k",")",":","scaling","factor","of","the","prior","precisions","on","the","mean","prior_weights",":","array","of","shape","(","k",")","the","prior","on","the","components","weights","shrinkage",":","array","of","shape","(","k",")",":","scaling","factor","of","the","posterior","precisions","on","the","mean","dof",":","array","of","shape","(","k",")",":","the","posterior","dofs","fixme","--","--","-","only","'full","'","precision","is","supported"]
docstr: Evaluate the Bayes Factor of the current model using Chib's method
  
  Parameters
  ----------
  x: array of shape (nb_samples,dim)
     the data from which bic is computed
  z: array of shape (nb_samples), type = np.int_
     the corresponding classification
  nperm=0: int
      the number of permutations to sample
      to model the label switching issue
      in the computation of the Bayes Factor
      By default, exhaustive permutations are used
  verbose=0: verbosity mode
  
  Returns
  -------
  bf (float) the computed evidence (Bayes factor)
  
  Notes
  -----
  See: Marginal Likelihood from the Gibbs Output
  Journal article by Siddhartha Chib;
  Journal of the American Statistical Association, Vol. 90, 1995
docstr_tok: ["Evaluate","the","Bayes","Factor","of","the","current","model","using","Chib","'s","method","Parameters","--","--","--","--","--","x",":","array","of","shape","(","nb_samples",",","dim",")","the","data","from","which","bic","is","computed","z",":","array","of","shape","(","nb_samples",")",",","type","=","np.int_","the","corresponding","classification","nperm=0",":","int","the","number","of","permutations","to","sample","to","model","the","label","switching","issue","in","the","computation","of","the","Bayes","Factor","By","default",",","exhaustive","permutations","are","used","verbose=0",":","verbosity","mode","Returns","--","--","--","-","bf","(","float",")","the","computed","evidence","(","Bayes","factor",")","Notes","--","--","-","See",":","Marginal","Likelihood","from","the","Gibbs","Output","Journal","article","by","Siddhartha","Chib",";","Journal","of","the","American","Statistical","Association",",","Vol",".","90",",","1995"]
code: def bayes_factor(self, x, z, nperm=0, verbose=0):
      """
      Evaluate the Bayes Factor of the current model using Chib's method
  
      Parameters
      ----------
      x: array of shape (nb_samples,dim)
         the data from which bic is computed
      z: array of shape (nb_samples), type = np.int_
         the corresponding classification
      nperm=0: int
          the number of permutations to sample
          to model the label switching issue
          in the computation of the Bayes Factor
          By default, exhaustive permutations are used
      verbose=0: verbosity mode
  
      Returns
      -------
      bf (float) the computed evidence (Bayes factor)
  
      Notes
      -----
      See: Marginal Likelihood from the Gibbs Output
      Journal article by Siddhartha Chib;
      Journal of the American Statistical Association, Vol. 90, 1995
      """
      niter = z.shape[1]
      p = []
      perm = generate_perm(self.k)
      if nperm > perm.shape[0]:
          nperm = perm.shape[0]
      for i in range(niter):
          if nperm == 0:
              temp = self.conditional_posterior_proba(x, z[:, i], perm)
              p.append(temp.mean())
          else:
              drand = np.argsort(np.random.rand(perm.shape[0]))[:nperm]
              temp = self.conditional_posterior_proba(
                  x, z[:, i], perm[drand]
              )
              p.append(temp.mean())
  
      p = np.array(p)
      mp = np.mean(p)
      p0 = self.probability_under_prior()
      like = self.likelihood(x)
      bf = np.log(p0) + np.sum(np.log(np.sum(like, 1))) - np.log(mp)
  
      if verbose:
          print(np.log(p0), np.sum(np.log(np.sum(like, 1))), np.log(mp))
      return bf
  
imports: import math
  import numpy
  import numpy.random
  from scipy.linalg import cholesky, eigvalsh, inv
  from scipy.special import gammaln
  from .gmm import GMM
  from .utils import kmeans
label_desc: Use image node_id 17 for calling the BGMM obj's underlying member method code with example usage: obj.bayes_factor(x, z, nperm, verbose) and returns: bf