class_docstr: Artefact detection with the Riemannian Potato.
  
  The Riemannian Potato [1]_ is a clustering method used to detect artifact
  in EEG signals. The algorithm iteratively estimates the centroid of clean
  signal by rejecting every trial that is too far from it.
  
  Parameters
  ----------
  metric : string, default='riemann'
      The type of metric used for centroid and distance estimation.
  threshold : float, default=3
      Threshold on z-score of distance to reject artifacts. It is the number
      of standard deviations from the mean of distances to the centroid.
  n_iter_max : int, default=100
      The maximum number of iteration to reach convergence.
  pos_label : int, default=1
      The positive label corresponding to clean data.
  neg_label : int, default=0
      The negative label corresponding to artifact data.
  
  Notes
  -----
  .. versionadded:: 0.2.3
  
  Attributes
  ----------
  covmean_ : ndarray, shape (n_channels, n_channels)
      Centroid of potato.
  
  See Also
  --------
  Kmeans
  MDM
  
  References
  ----------
  .. [1] `The Riemannian Potato: an automatic and adaptive artifact detection
      method for online experiments using Riemannian geometry
      <https://hal.archives-ouvertes.fr/hal-00781701>`_
      A. Barachant, A Andreev, and M. Congedo. TOBI Workshop lV, Jan 2013,
      Sion, Switzerland. pp.19-20.
  .. [2] `The Riemannian Potato Field: A Tool for Online Signal Quality Index
      of EEG
      <https://hal.archives-ouvertes.fr/hal-02015909>`_
      Q. Barthélemy, L. Mayaud, D. Ojeda, and M. Congedo. IEEE Transactions
      on Neural Systems and Rehabilitation Engineering, IEEE Institute of
      Electrical and Electronics Engineers, 2019, 27 (2), pp.244-255
docstr: Fit the potato from covariance matrices.
  
  Fit the potato from covariance matrices, with an iterative outlier
  removal to obtain a reliable potato.
  
  Parameters
  ----------
  X : ndarray, shape (n_matrices, n_channels, n_channels)
      Set of SPD matrices.
  y : None | ndarray, shape (n_matrices,), default=None
      Labels corresponding to each matrix: positive (resp. negative)
      label corresponds to a clean (resp. artifact) matrix.
      If None, all matrices are considered as clean.
  
  Returns
  -------
  self : Potato instance
      The Potato instance.
docstr_tok: ["Fit","the","potato","from","covariance","matrices",".","Fit","the","potato","from","covariance","matrices",",","with","an","iterative","outlier","removal","to","obtain","a","reliable","potato",".","Parameters","--","--","--","--","--","X",":","ndarray",",","shape","(","n_matrices",",","n_channels",",","n_channels",")","Set","of","SPD","matrices",".","y",":","None","|","ndarray",",","shape","(","n_matrices",",",")",",","default=None","Labels","corresponding","to","each","matrix",":","positive","(","resp",".","negative",")","label","corresponds","to","a","clean","(","resp",".","artifact",")","matrix",".","If","None",",","all","matrices","are","considered","as","clean",".","Returns","--","--","--","-","self",":","Potato","instance","The","Potato","instance","."]
code: def fit(self, X, y=None):
      """Fit the potato from covariance matrices.
  
      Fit the potato from covariance matrices, with an iterative outlier
      removal to obtain a reliable potato.
  
      Parameters
      ----------
      X : ndarray, shape (n_matrices, n_channels, n_channels)
          Set of SPD matrices.
      y : None | ndarray, shape (n_matrices,), default=None
          Labels corresponding to each matrix: positive (resp. negative)
          label corresponds to a clean (resp. artifact) matrix.
          If None, all matrices are considered as clean.
  
      Returns
      -------
      self : Potato instance
          The Potato instance.
      """
      if self.pos_label == self.neg_label:
          raise ValueError(
              "Positive and negative labels must be different"
          )
  
      self._mdm = MDM(metric=self.metric)
      self._mdm.metric_mean, self._mdm.metric_dist = _check_metric(
          self.metric
      )
  
      y_old = self._check_labels(X, y)
  
      for _ in range(self.n_iter_max):
          ix = y_old == 1
          if not any(ix):
              raise ValueError(
                  "Iterative outlier removal has rejected all "
                  "matrices. Choose a higher threshold."
              )
          self._mdm.fit(X[ix], y_old[ix])
          y = np.zeros(len(X))
          d = np.squeeze(np.log(self._mdm.transform(X[ix])))
          self._mean = np.mean(d)
          self._std = np.std(d)
          y[ix] = self._get_z_score(d) < self.threshold
  
          if np.array_equal(y, y_old):
              break
          else:
              y_old = y
  
      self.covmean_ = self._mdm.covmeans_[0]
      return self
  
imports: import numpy
  from joblib import Parallel, delayed
  from scipy.stats import norm, chi2
  import sklearn
  from sklearn.base import BaseEstimator, ClassifierMixin, TransformerMixin, ClusterMixin, clone
  from sklearn.cluster import KMeans
  from .classification import MDM, _check_metric
  from .utils.mean import mean_covariance
  from .utils.geodesic import geodesic
label_desc: Use image node_id 2 for calling the Potato obj's underlying member method code with example usage: obj.fit(X, y) and returns: self