class_docstr: Class for K-medoids clustering on manifolds.
  
  K-medoids algorithm using Riemannian manifolds.
  
  Parameters
  ----------
  space : Manifold
      Equipped manifold.
  n_clusters : int
      Number of clusters (k value of k-medoids).
      Optional, default: 8.
  max_iter : int
      Maximum number of iterations.
      Optional, default: 100.
  init : str
      How to initialize cluster centers at the beginning of the algorithm. The
      choice 'random' will select training points as initial cluster centers
      uniformly at random.
      Optional, default: 'random'.
  n_jobs : int
      Number of jobs to run in parallel. `-1` means using all processors.
      Optional, default: 1.
  
  Notes
  -----
  * Required metric methods: `dist`, `dist_pairwise`.
  
  Example
  -------
  Available example on the Poincaré Ball and Hypersphere manifolds
  :mod:`examples.plot_kmedoids_manifolds`
class_docstr_tok: ["Class","for","K-medoids","clustering","on","manifolds",".","K-medoids","algorithm","using","Riemannian","manifolds",".","Parameters","--","--","--","--","--","space",":","Manifold","Equipped","manifold",".","n_clusters",":","int","Number","of","clusters","(","k","value","of","k-medoids",")",".","Optional",",","default",":","8.","max_iter",":","int","Maximum","number","of","iterations",".","Optional",",","default",":","100.","init",":","str","How","to","initialize","cluster","centers","at","the","beginning","of","the","algorithm",".","The","choice","'random","'","will","select","training","points","as","initial","cluster","centers","uniformly","at","random",".","Optional",",","default",":","'random","'",".","n_jobs",":","int","Number","of","jobs","to","run","in","parallel",".","`","-1","`","means","using","all","processors",".","Optional",",","default",":","1",".","Notes","--","--","-","*","Required","metric","methods",":","`","dist","`",",","`","dist_pairwise","`",".","Example","--","--","--","-","Available","example","on","the","Poincar\u00e9","Ball","and","Hypersphere","manifolds",":","mod",":","`","examples.plot_kmedoids_manifolds","`"]
docstr: Provide cluster centers and data labels.
  
  Labels data by minimizing the distance between data points
  and cluster center chosen from the data points.
  Minimization is performed by swapping the cluster centers and data points.
  
  Parameters
  ----------
  X : array-like, shape=[n_samples, dim]
      Training data, where n_samples is the number of samples and
      dim is the number of dimensions.
  
  Returns
  -------
  self : object
      Returns self.
docstr_tok: ["Provide","cluster","centers","and","data","labels",".","Labels","data","by","minimizing","the","distance","between","data","points","and","cluster","center","chosen","from","the","data","points",".","Minimization","is","performed","by","swapping","the","cluster","centers","and","data","points",".","Parameters","--","--","--","--","--","X",":","array-like",",","shape=","[","n_samples",",","dim","]","Training","data",",","where","n_samples","is","the","number","of","samples","and","dim","is","the","number","of","dimensions",".","Returns","--","--","--","-","self",":","object","Returns","self","."]
code: def fit(self, X):
      """Provide cluster centers and data labels.
  
      Labels data by minimizing the distance between data points
      and cluster center chosen from the data points.
      Minimization is performed by swapping the cluster centers and data points.
  
      Parameters
      ----------
      X : array-like, shape=[n_samples, dim]
          Training data, where n_samples is the number of samples and
          dim is the number of dimensions.
  
      Returns
      -------
      self : object
          Returns self.
      """
      distances = self.space.metric.dist_pairwise(X, n_jobs=self.n_jobs)
      medoids_indices = self._initialize_medoids(distances)
  
      for iteration in range(self.max_iter):
          old_medoids_indices = gs.copy(medoids_indices)
          labels = gs.argmin(distances[medoids_indices, :], axis=0)
          self._update_medoid_indexes(
              distances, labels, medoids_indices
          )
  
          if gs.all(old_medoids_indices == medoids_indices):
              break
          if iteration == self.max_iter - 1:
              logging.warning(
                  "Maximum number of iteration reached before "
                  "convergence. Consider increasing max_iter to "
                  "improve the fit."
              )
  
      self.cluster_centers_ = X[medoids_indices]
      self.labels_ = labels
      self.medoid_indices_ = medoids_indices
  
      return self
  
file_path: geomstats/geomstats/learning/kmedoids.py
imports: import logging
  from sklearn.base import BaseEstimator, ClusterMixin
  import geomstats.backend
  from geomstats.learning._template import TransformerMixin
label_desc: Use image node_id 3 for calling the RiemannianKMedoids obj's underlying member method code with example usage: obj.fit(X) and returns: self