class_docstr: Class for Riemannian Mean Shift algorithm on manifolds.
  
  Mean Shift is a procedure for locating the maxima - the modes of a
  density function given discrete data sampled from that function. It is
  an iterative method for finding the centers of a collection of clusters.
  
  Following implementation assumes a flat kernel method.
  
  Parameters
  ----------
  space : Manifold
      Equipped manifold.
  bandwidth : float
      Size of neighbourhood around each center. All points in 'bandwidth'
      size around center are considered for calculating new mean centers.
  tol : float
      Stopping condition. Computation of subsequent mean centers is stopped
      when the distance between them is less than 'tol'.
      Optional, default : 1e-2.
  n_clusters : int
      Number of centers.
      Optional, default : 1.
  n_jobs : int
      Number of parallel threads to be initiated for parallel jobs.
      Optional, default : 1.
  max_iter : int
      Upper bound on total number of iterations for the centers to converge.
      Optional, default : 100.
  init_centers : str
      Initializing centers, either from the given input points or
      random points uniformly distributed in the input manifold.
      Optional, default : "from_points".
  kernel : str
      Weighing function to assign kernel weights to each center.
      Optional, default : "flat".
  
  Notes
  -----
  * Required metric methods: `dist`, `closest_neighbor_index`.
class_docstr_tok: ["Class","for","Riemannian","Mean","Shift","algorithm","on","manifolds",".","Mean","Shift","is","a","procedure","for","locating","the","maxima","-","the","modes","of","a","density","function","given","discrete","data","sampled","from","that","function",".","It","is","an","iterative","method","for","finding","the","centers","of","a","collection","of","clusters",".","Following","implementation","assumes","a","flat","kernel","method",".","Parameters","--","--","--","--","--","space",":","Manifold","Equipped","manifold",".","bandwidth",":","float","Size","of","neighbourhood","around","each","center",".","All","points","in","'bandwidth'","size","around","center","are","considered","for","calculating","new","mean","centers",".","tol",":","float","Stopping","condition",".","Computation","of","subsequent","mean","centers","is","stopped","when","the","distance","between","them","is","less","than","'tol","'",".","Optional",",","default",":","1e-2",".","n_clusters",":","int","Number","of","centers",".","Optional",",","default",":","1.","n_jobs",":","int","Number","of","parallel","threads","to","be","initiated","for","parallel","jobs",".","Optional",",","default",":","1.","max_iter",":","int","Upper","bound","on","total","number","of","iterations","for","the","centers","to","converge",".","Optional",",","default",":","100.","init_centers",":","str","Initializing","centers",",","either","from","the","given","input","points","or","random","points","uniformly","distributed","in","the","input","manifold",".","Optional",",","default",":","``","from_points","''",".","kernel",":","str","Weighing","function","to","assign","kernel","weights","to","each","center",".","Optional",",","default",":","``","flat","''",".","Notes","--","--","-","*","Required","metric","methods",":","`","dist","`",",","`","closest_neighbor_index","`","."]
docstr: Fit centers in all the input points.
  
  Parameters
  ----------
  X : array-like, shape=[n_samples, n_features]
      Clusters of points.
  y : None
      Target values. Ignored.
  
  Returns
  -------
  self : object
      Returns self.
docstr_tok: ["Fit","centers","in","all","the","input","points",".","Parameters","--","--","--","--","--","X",":","array-like",",","shape=","[","n_samples",",","n_features","]","Clusters","of","points",".","y",":","None","Target","values",".","Ignored",".","Returns","--","--","--","-","self",":","object","Returns","self","."]
code: def fit(self, X, y=None):
      """Fit centers in all the input points.
  
      Parameters
      ----------
      X : array-like, shape=[n_samples, n_features]
          Clusters of points.
      y : None
          Target values. Ignored.
  
      Returns
      -------
      self : object
          Returns self.
      """
  
      @joblib.delayed
      @joblib.wrap_non_picklable_objects
      def pickable_mean(points, weights):
          """Frechet Mean of all points weighted by weights.
  
          Parameters
          ----------
          points : array-like, shape=[..., n_features]
              Clusters of points.
          weights : array-like,
              Weight associated with each point in cluster.
          """
          return self.mean_estimator.fit(
              points, weights=weights
          ).estimate_
  
      centers = self._initialization(X)
  
      for _ in range(self.max_iter):
          dists = self._dist_intersets(centers, X)
  
          if self.kernel == "flat":
              weights = gs.ones_like(dists)
  
          weights[dists > self.bandwidth] = 0.0
          weights = weights / gs.sum(weights, axis=1, keepdims=True)
  
          points_to_average, nonzero_weights = [], []
  
          for j in range(self.n_clusters):
              indexes = gs.where(weights[j] > 0)
              nonzero_weights += [
                  weights[j][indexes],
              ]
              points_to_average += [
                  X[indexes],
              ]
  
          pool = joblib.Parallel(n_jobs=self.n_jobs)
          out = pool(
              pickable_mean(points_to_average[j], nonzero_weights[j])
              for j in range(self.n_clusters)
          )
  
          new_centers = gs.array(out)
  
          displacements = [self.space.metric.dist(centers, new_centers)]
          centers = new_centers
  
          if (gs.array(displacements) < self.tol).all():
              break
  
      self.cluster_centers_ = centers
  
      return self
  
file_path: geomstats/geomstats/learning/riemannian_mean_shift.py
imports: import joblib
  from sklearn.base import BaseEstimator, ClusterMixin
  import geomstats.backend
  from geomstats.learning.frechet_mean import FrechetMean
label_desc: Use image node_id 4 for calling the RiemannianMeanShift obj's underlying member method code with example usage: obj.fit(X, y) and returns: self, self