class_docstr: K-neighbors density estimation
  
  Parameters
  ----------
  method : string
      method to use.  Must be one of ['simple'|'bayesian'] (see below)
  n_neighbors : int
      number of neighbors to use
  
  Notes
  -----
  The two methods are as follows:
  
  - simple:
      The density at a point x is estimated by n(x) ~ k / r_k^n
  - bayesian:
      The density at a point x is estimated by n(x) ~ sum_{i=1}^k[1 / r_i^n].
  
  See Also
  --------
  KDE : kernel density estimation
docstr: Train the K-neighbors density estimator
  
  Parameters
  ----------
  X : array_like
      array of points to use to train the KDE.  Shape is
      (n_points, n_dim)
code: def fit(self, X):
      """Train the K-neighbors density estimator
  
      Parameters
      ----------
      X : array_like
          array of points to use to train the KDE.  Shape is
          (n_points, n_dim)
      """
      self.X_ = np.atleast_2d(X)
  
      if self.X_.ndim != 2:
          raise ValueError("X must be two-dimensional")
  
      self.bt_ = BallTree(self.X_)
  
      return self
  
file_path: astroML/astroML/density_estimation/density_estimation.py
imports: import numpy
  from scipy import special
  from sklearn.base import BaseEstimator
  from sklearn.neighbors import BallTree
label_desc: Use image node_id 2 for calling the KNeighborsDensity obj's underlying member method code with example usage: obj.fit(X) and returns: self