class_docstr: Variational Inference for the Infinite Gaussian Mixture Model.
  
  DPGMM stands for Dirichlet Process Gaussian Mixture Model, and it
  is an infinite mixture model with the Dirichlet Process as a prior
  distribution on the number of clusters. In practice the
  approximate inference algorithm uses a truncated distribution with
  a fixed maximum number of components, but almost always the number
  of components actually used depends on the data.
  
  Stick-breaking Representation of a Gaussian mixture model
  probability distribution. This class allows for easy and efficient
  inference of an approximate posterior distribution over the
  parameters of a Gaussian mixture model with a variable number of
  components (smaller than the truncation parameter n_components).
  
  Initialization is with normally-distributed means and identity
  covariance, for proper convergence.
  
  Read more in the :ref:`User Guide <dpgmm>`.
  
  Parameters
  ----------
  n_components: int, default 1
      Number of mixture components.
  
  covariance_type: string, default 'diag'
      String describing the type of covariance parameters to
      use.  Must be one of 'spherical', 'tied', 'diag', 'full'.
  
  alpha: float, default 1
      Real number representing the concentration parameter of
      the dirichlet process. Intuitively, the Dirichlet Process
      is as likely to start a new cluster for a point as it is
      to add that point to a cluster with alpha elements. A
      higher alpha means more clusters, as the expected number
      of clusters is ``alpha*log(N)``.
  
  tol : float, default 1e-3
      Convergence threshold.
  
  n_iter : int, default 10
      Maximum number of iterations to perform before convergence.
  
  params : string, default 'wmc'
      Controls which parameters are updated in the training
      process.  Can contain any combination of 'w' for weights,
      'm' for means, and 'c' for covars.
  
  init_params : string, default 'wmc'
      Controls which parameters are updated in the initialization
      process.  Can contain any combination of 'w' for weights,
      'm' for means, and 'c' for covars.  Defaults to 'wmc'.
  
  verbose : int, default 0
      Controls output verbosity.
  
  Attributes
  ----------
  covariance_type : string
      String describing the type of covariance parameters used by
      the DP-GMM.  Must be one of 'spherical', 'tied', 'diag', 'full'.
  
  n_components : int
      Number of mixture components.
  
  weights_ : array, shape (`n_components`,)
      Mixing weights for each mixture component.
  
  means_ : array, shape (`n_components`, `n_features`)
      Mean parameters for each mixture component.
  
  precs_ : array
      Precision (inverse covariance) parameters for each mixture
      component.  The shape depends on `covariance_type`::
  
          (`n_components`, 'n_features')                if 'spherical',
          (`n_features`, `n_features`)                  if 'tied',
          (`n_components`, `n_features`)                if 'diag',
          (`n_components`, `n_features`, `n_features`)  if 'full'
  
  converged_ : bool
      True when convergence was reached in fit(), False otherwise.
  
  See Also
  --------
  GMM : Finite Gaussian mixture model fit with EM
  
  VBGMM : Finite Gaussian mixture model fit with a variational
      algorithm, better for situations where there might be too little
      data to get a good estimate of the covariance matrix.
docstr: Return the likelihood of the data under the model.
  
  Compute the bound on log probability of X under the model
  and return the posterior distribution (responsibilities) of
  each mixture component for each element of X.
  
  This is done by computing the parameters for the mean-field of
  z for each observation.
  
  Parameters
  ----------
  X : array_like, shape (n_samples, n_features)
      List of n_features-dimensional data points.  Each row
      corresponds to a single data point.
  
  Returns
  -------
  logprob : array_like, shape (n_samples,)
      Log probabilities of each data point in X
  responsibilities : array_like, shape (n_samples, n_components)
      Posterior probabilities of each mixture component for each
      observation
docstr_tok: ["Return","the","likelihood","of","the","data","under","the","model",".","Compute","the","bound","on","log","probability","of","X","under","the","model","and","return","the","posterior","distribution","(","responsibilities",")","of","each","mixture","component","for","each","element","of","X",".","This","is","done","by","computing","the","parameters","for","the","mean-field","of","z","for","each","observation",".","Parameters","--","--","--","--","--","X",":","array_like",",","shape","(","n_samples",",","n_features",")","List","of","n_features-dimensional","data","points",".","Each","row","corresponds","to","a","single","data","point",".","Returns","--","--","--","-","logprob",":","array_like",",","shape","(","n_samples",",",")","Log","probabilities","of","each","data","point","in","X","responsibilities",":","array_like",",","shape","(","n_samples",",","n_components",")","Posterior","probabilities","of","each","mixture","component","for","each","observation"]
code: def score_samples(self, X):
      """Return the likelihood of the data under the model.
  
      Compute the bound on log probability of X under the model
      and return the posterior distribution (responsibilities) of
      each mixture component for each element of X.
  
      This is done by computing the parameters for the mean-field of
      z for each observation.
  
      Parameters
      ----------
      X : array_like, shape (n_samples, n_features)
          List of n_features-dimensional data points.  Each row
          corresponds to a single data point.
  
      Returns
      -------
      logprob : array_like, shape (n_samples,)
          Log probabilities of each data point in X
      responsibilities : array_like, shape (n_samples, n_components)
          Posterior probabilities of each mixture component for each
          observation
      """
      check_is_fitted(self, "gamma_")
  
      X = check_array(X)
      if X.ndim == 1:
          X = X[:, np.newaxis]
      z = np.zeros((X.shape[0], self.n_components))
      sd = digamma(self.gamma_.T[1] + self.gamma_.T[2])
      dgamma1 = digamma(self.gamma_.T[1]) - sd
      dgamma2 = np.zeros(self.n_components)
      dgamma2[0] = digamma(self.gamma_[0, 2]) - digamma(
          self.gamma_[0, 1] + self.gamma_[0, 2]
      )
      for j in range(1, self.n_components):
          dgamma2[j] = dgamma2[j - 1] + digamma(self.gamma_[j - 1, 2])
          dgamma2[j] -= sd[j - 1]
      dgamma = dgamma1 + dgamma2
      # Free memory and developers cognitive load:
      del dgamma1, dgamma2, sd
  
      if self.covariance_type not in [
          "full",
          "tied",
          "diag",
          "spherical",
      ]:
          raise NotImplementedError(
              "This ctype is not implemented: %s" % self.covariance_type
          )
      p = _bound_state_log_lik(
          X,
          self._initial_bound + self.bound_prec_,
          self.precs_,
          self.means_,
          self.covariance_type,
      )
      z = p + dgamma
      z = log_normalize(z, axis=-1)
      bound = np.sum(z * p, axis=-1)
      return bound, z
  
imports: from __future__ import print_function
  import numpy
  from scipy.special import digamma, gammaln
  from scipy import linalg
  from scipy.spatial.distance import cdist
  from ..externals.six.moves import xrange
  from ..utils import check_random_state, check_array, deprecated
  from ..utils.extmath import logsumexp, pinvh, squared_norm
  from ..utils.validation import check_is_fitted
  from ..None import cluster
  from .gmm import _GMMBase
label_desc: Use image node_id 5 for calling the _DPGMMBase obj's underlying member method code with example usage: obj.score_samples(X) and returns: bound,  z