class_docstr: Class for k-means clustering on manifolds.
  
  K-means algorithm using Riemannian manifolds.
  
  Parameters
  ----------
  space : Manifold
      Equipped manifold.
  n_clusters : int
      Number of clusters (k value of the k-means).
      Optional, default: 8.
  init : str or callable or array-like, shape=[n_clusters, n_features]
      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. The choice 'kmeans++' selects cluster centers
      heuristically to improve the convergence rate. When providing an array
      of shape ``(n_clusters, n_features)``, the cluster centers are chosen as the
      rows of that array. When providing a callable, it receives as arguments
      the argument ``X`` to :meth:`fit` and the number of cluster centers
      ``n_clusters`` and is expected to return an array as above.
      Optional, default: 'random'.
  tol : float
      Convergence factor. Convergence is achieved when the difference of mean
      distance between two steps is lower than tol.
      Optional, default: 1e-2.
  max_iter : int
      Maximum number of iterations.
      Optional, default: 100
  verbose : int
      If verbose > 0, information will be printed during learning.
      Optional, default: 0.
  
  Notes
  -----
  * Required metric methods: `dist`.
  
  Example
  -------
  Available example on the Poincaré Ball and Hypersphere manifolds
  :mod:`examples.plot_kmeans_manifolds`
class_docstr_tok: ["Class","for","k-means","clustering","on","manifolds",".","K-means","algorithm","using","Riemannian","manifolds",".","Parameters","--","--","--","--","--","space",":","Manifold","Equipped","manifold",".","n_clusters",":","int","Number","of","clusters","(","k","value","of","the","k-means",")",".","Optional",",","default",":","8.","init",":","str","or","callable","or","array-like",",","shape=","[","n_clusters",",","n_features","]","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",".","The","choice","'kmeans++","'","selects","cluster","centers","heuristically","to","improve","the","convergence","rate",".","When","providing","an","array","of","shape","``","(","n_clusters",",","n_features",")","``",",","the","cluster","centers","are","chosen","as","the","rows","of","that","array",".","When","providing","a","callable",",","it","receives","as","arguments","the","argument","``","X","``","to",":","meth",":","`","fit","`","and","the","number","of","cluster","centers","``","n_clusters","``","and","is","expected","to","return","an","array","as","above",".","Optional",",","default",":","'random","'",".","tol",":","float","Convergence","factor",".","Convergence","is","achieved","when","the","difference","of","mean","distance","between","two","steps","is","lower","than","tol",".","Optional",",","default",":","1e-2",".","max_iter",":","int","Maximum","number","of","iterations",".","Optional",",","default",":","100","verbose",":","int","If","verbose",">","0",",","information","will","be","printed","during","learning",".","Optional",",","default",":","0",".","Notes","--","--","-","*","Required","metric","methods",":","`","dist","`",".","Example","--","--","--","-","Available","example","on","the","Poincar\u00e9","Ball","and","Hypersphere","manifolds",":","mod",":","`","examples.plot_kmeans_manifolds","`"]
docstr: Predict the labels for each data point.
  
  Label each data point with the cluster having the nearest
  cluster center using metric distance.
  
  Parameters
  ----------
  X : array-like, shape[n_samples, n_features]
      Input data.
  
  Returns
  -------
  labels : array-like, shape=[n_samples,]
      Array of predicted cluster indices for each sample.
docstr_tok: ["Predict","the","labels","for","each","data","point",".","Label","each","data","point","with","the","cluster","having","the","nearest","cluster","center","using","metric","distance",".","Parameters","--","--","--","--","--","X",":","array-like",",","shape","[","n_samples",",","n_features","]","Input","data",".","Returns","--","--","--","-","labels",":","array-like",",","shape=","[","n_samples",",","]","Array","of","predicted","cluster","indices","for","each","sample","."]
code: def predict(self, X):
      """Predict the labels for each data point.
  
      Label each data point with the cluster having the nearest
      cluster center using metric distance.
  
      Parameters
      ----------
      X : array-like, shape[n_samples, n_features]
          Input data.
  
      Returns
      -------
      labels : array-like, shape=[n_samples,]
          Array of predicted cluster indices for each sample.
      """
      if self.cluster_centers_ is None:
          raise RuntimeError("fit needs to be called first.")
      dists = gs.stack(
          [
              self.space.metric.dist(cluster_center, X)
              for cluster_center in self.cluster_centers_
          ],
          axis=1,
      )
      dists = gs.squeeze(dists)
  
      labels = gs.argmin(dists, -1)
  
      return labels
  
file_path: geomstats/geomstats/learning/kmeans.py
imports: import logging
  from random import randint
  from scipy.stats import rv_discrete
  from sklearn.base import BaseEstimator, ClusterMixin
  import geomstats.backend
  from geomstats.learning._template import TransformerMixin
  from geomstats.learning.frechet_mean import FrechetMean
label_desc: Use image node_id 4 for calling the RiemannianKMeans obj's underlying member method code with example usage: obj.predict(X) and returns: labels