class_docstr: kNN classification method adapted for multi-label classification
  
  MLkNN builds uses k-NearestNeighbors find nearest examples to a test class and uses Bayesian inference
  to select assigned labels.
  
  Parameters
  ----------
  k : int
      number of neighbours of each input instance to take into account
  s: float (default is 1.0)
      the smoothing parameter
  ignore_first_neighbours : int (default is 0)
      ability to ignore first N neighbours, useful for comparing
      with other classification software.
  n_jobs: int or None, optional (default=None)
      The number of parallel jobs to run for neighbors search. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors.
  
  Attributes
  ----------
  knn_ : an instance of sklearn.NearestNeighbors
      the nearest neighbors single-label classifier used underneath
  
  
  
  .. note:: If you don't know what :code:`ignore_first_neighbours`
            does, the default is safe. Please see this `issue`_.
  
  
  .. _issue: https://github.com/scikit-multilearn/scikit-multilearn/issues/22
  
  
  References
  ----------
  
  If you use this classifier please cite the original paper introducing the method:
  
  .. code :: bibtex
  
      @article{zhang2007ml,
        title={ML-KNN: A lazy learning approach to multi-label learning},
        author={Zhang, Min-Ling and Zhou, Zhi-Hua},
        journal={Pattern recognition},
        volume={40},
        number={7},
        pages={2038--2048},
        year={2007},
        publisher={Elsevier}
      }
  
  Examples
  --------
  
  Here's a very simple example of using MLkNN with a fixed number of neighbors:
  
  .. code :: python
  
      from skmultilearn.adapt import MLkNN
  
      classifier = MLkNN(k=3)
  
      # train
      classifier.fit(X_train, y_train)
  
      # predict
      predictions = classifier.predict(X_test)
  
  
  You can also use :class:`~sklearn.model_selection.GridSearchCV` to find an optimal set of parameters:
  
  .. code :: python
  
      from skmultilearn.adapt import MLkNN
      from sklearn.model_selection import GridSearchCV
  
      parameters = {'k': range(1,3), 's': [0.5, 0.7, 1.0]}
      score = 'f1_macro'
  
      clf = GridSearchCV(MLkNN(), parameters, scoring=score)
      clf.fit(X, y)
  
      print (clf.best_params_, clf.best_score_)
  
      # output
      ({'k': 1, 's': 0.5}, 0.78988303374297597)
docstr: Predict probabilities of label assignments for X
  
  Parameters
  ----------
  X : numpy.ndarray or scipy.sparse.csc_matrix
      input features of shape :code:`(n_samples, n_features)`
  
  Returns
  -------
  scipy.sparse matrix of int
      binary indicator matrix with label assignment probabilities
      with shape :code:`(n_samples, n_labels)`
docstr_tok: ["Predict","probabilities","of","label","assignments","for","X","Parameters","--","--","--","--","--","X",":","numpy.ndarray","or","scipy.sparse.csc_matrix","input","features","of","shape",":","code",":","`","(","n_samples",",","n_features",")","`","Returns","--","--","--","-","scipy.sparse","matrix","of","int","binary","indicator","matrix","with","label","assignment","probabilities","with","shape",":","code",":","`","(","n_samples",",","n_labels",")","`"]
code: def predict_proba(self, X):
      """Predict probabilities of label assignments for X
  
      Parameters
      ----------
      X : numpy.ndarray or scipy.sparse.csc_matrix
          input features of shape :code:`(n_samples, n_features)`
  
      Returns
      -------
      scipy.sparse matrix of int
          binary indicator matrix with label assignment probabilities
          with shape :code:`(n_samples, n_labels)`
      """
      result = sparse.lil_matrix(
          (X.shape[0], self._num_labels), dtype="float"
      )
      neighbors = [
          a[self.ignore_first_neighbours :]
          for a in self.knn_.kneighbors(
              X,
              self.k + self.ignore_first_neighbours,
              return_distance=False,
          )
      ]
      for instance in range(X.shape[0]):
          deltas = self._label_cache[neighbors[instance],].sum(axis=0)
  
          for label in range(self._num_labels):
              p_true = (
                  self._prior_prob_true[label]
                  * self._cond_prob_true[label, deltas[0, label]]
              )
              p_false = (
                  self._prior_prob_false[label]
                  * self._cond_prob_false[label, deltas[0, label]]
              )
              result[instance, label] = p_true / (p_true + p_false)
  
      return result
  
file_path: scikit-multilearn/skmultilearn/adapt/mlknn.py
imports: from builtins import range
  from ..base import MLClassifierBase
  from ..utils import get_matrix_in_format
  from sklearn.neighbors import NearestNeighbors
  import numpy
  import scipy.sparse
label_desc: Use image node_id 6 for calling the MLkNN obj's underlying member method code with example usage: obj.predict_proba(X) and returns: result