class_docstr: GaussianMixture Bayes Classifier
  
  This is a generalization to the Naive Bayes classifier: rather than
  modeling the distribution of each class with axis-aligned gaussians,
  GMMBayes models the distribution of each class with mixtures of
  gaussians.  This can lead to better classification in some cases.
  
  Parameters
  ----------
  n_components : int or list
      number of components to use in the GaussianMixture. If specified as
      a list, it must match the number of class labels. Default is 1.
  **kwargs : dict, optional
      other keywords are passed directly to GaussianMixture
code: def fit(self, X, y):
      X = self._check_X(X)
      y = np.asarray(y)
  
      n_samples, n_features = X.shape
  
      if n_samples != y.shape[0]:
          raise ValueError("X and y have incompatible shapes")
  
      self.classes_ = np.unique(y)
      self.classes_.sort()
      unique_y = self.classes_
  
      n_classes = unique_y.shape[0]
  
      if self.n_components.size not in (1, len(unique_y)):
          raise ValueError(
              "n_components must be compatible with "
              "the number of classes"
          )
  
      self.gmms_ = [None for i in range(n_classes)]
      self.class_prior_ = np.zeros(n_classes)
  
      n_comp = (
          np.zeros(len(self.classes_), dtype=int) + self.n_components
      )
  
      for i, y_i in enumerate(unique_y):
          if n_comp[i] > X[y == y_i].shape[0]:
              warnstr = (
                  "Expected n_samples >= n_components but got "
                  "n_samples={0}, n_components={1}, "
                  "n_components set to {0}."
              )
              warnings.warn(
                  warnstr.format(X[y == y_i].shape[0], n_comp[i])
              )
              n_comp[i] = X[y == y_i].shape[0]
          self.gmms_[i] = GaussianMixture(n_comp[i], **self.kwargs).fit(
              X[y == y_i]
          )
          self.class_prior_[i] = float(np.sum(y == y_i)) / n_samples
  
      return self
  
file_path: astroML/astroML/classification/gmm_bayes.py
imports: import warnings
  import numpy
  from sklearn.mixture import GaussianMixture
  from sklearn.utils import check_array
label_desc: Use image node_id 2 for calling the GMMBayes obj's underlying member method code with example usage: obj.fit(X, y) and returns: self