class_docstr: Extreme Deconvolution
  
  Fit an extreme deconvolution (XD) model to the data
  
  Parameters
  ----------
  n_components: integer
      number of gaussian components to fit to the data
  max_iter: integer (optional)
      number of EM iterations to perform (default=100)
  tol: float (optional)
      stopping criterion for EM iterations (default=1E-5)
  
  Notes
  -----
  This implementation follows Bovy et al. arXiv 0905.2979
class_docstr_tok: ["Extreme","Deconvolution","Fit","an","extreme","deconvolution","(","XD",")","model","to","the","data","Parameters","--","--","--","--","--","n_components",":","integer","number","of","gaussian","components","to","fit","to","the","data","max_iter",":","integer","(","optional",")","number","of","EM","iterations","to","perform","(","default=100",")","tol",":","float","(","optional",")","stopping","criterion","for","EM","iterations","(","default=1E-5",")","Notes","--","--","-","This","implementation","follows","Bovy","et","al",".","arXiv","0905.2979"]
docstr: Fit the XD model to data
  
  Parameters
  ----------
  X: array_like
      Input data. shape = (n_samples, n_features)
  Xerr: array_like
      Error on input data.  shape = (n_samples, n_features, n_features)
  R : array_like
      (TODO: not implemented)
      Transformation matrix from underlying to observed data.  If
      unspecified, then it is assumed to be the identity matrix.
docstr_tok: ["Fit","the","XD","model","to","data","Parameters","--","--","--","--","--","X",":","array_like","Input","data",".","shape","=","(","n_samples",",","n_features",")","Xerr",":","array_like","Error","on","input","data",".","shape","=","(","n_samples",",","n_features",",","n_features",")","R",":","array_like","(","TODO",":","not","implemented",")","Transformation","matrix","from","underlying","to","observed","data",".","If","unspecified",",","then","it","is","assumed","to","be","the","identity","matrix","."]
code: def fit(self, X, Xerr, R=None):
      """Fit the XD model to data
  
      Parameters
      ----------
      X: array_like
          Input data. shape = (n_samples, n_features)
      Xerr: array_like
          Error on input data.  shape = (n_samples, n_features, n_features)
      R : array_like
          (TODO: not implemented)
          Transformation matrix from underlying to observed data.  If
          unspecified, then it is assumed to be the identity matrix.
      """
      if R is not None:
          raise NotImplementedError(
              "mixing matrix R is not yet implemented"
          )
  
      X = np.asarray(X)
      Xerr = np.asarray(Xerr)
      n_samples, n_features = X.shape
  
      # assume full covariances of data
      assert Xerr.shape == (n_samples, n_features, n_features)
  
      # initialize components via a few steps of GaussianMixture
      # this doesn't take into account errors, but is a fast first-guess
      gmm = GaussianMixture(
          self.n_components,
          max_iter=10,
          covariance_type="full",
          random_state=self.random_state,
      ).fit(X)
      self.mu = gmm.means_
      self.alpha = gmm.weights_
      self.V = gmm.covariances_
  
      logL = self.logL(X, Xerr)
  
      for i in range(self.max_iter):
          t0 = time()
          self._EMstep(X, Xerr)
          logL_next = self.logL(X, Xerr)
          t1 = time()
  
          if self.verbose:
              print("%i: log(L) = %.5g" % (i + 1, logL_next))
              print("    (%.2g sec)" % (t1 - t0))
  
          if logL_next < logL + self.tol:
              break
          logL = logL_next
  
      return self
  
file_path: astroML/astroML/density_estimation/xdeconv.py
imports: from time import time
  import numpy
  from scipy import linalg
  from sklearn.base import BaseEstimator
  from sklearn.mixture import GaussianMixture
  from sklearn.utils import check_random_state
  from ..utils import log_multivariate_gaussian
label_desc: Use image node_id 2 for calling the XDGMM obj's underlying member method code with example usage: obj.fit(X, Xerr, R) and returns: self