class_docstr: Base class for KMeans and MiniBatchKMeans
class_docstr_tok: ["Base","class","for","KMeans","and","MiniBatchKMeans"]
docstr: Predict the closest cluster each sample in X belongs to.
  
  In the vector quantization literature, `cluster_centers_` is called
  the code book and each value returned by `predict` is the index of
  the closest code in the code book.
  
  Parameters
  ----------
  X : {array-like, sparse matrix} of shape (n_samples, n_features)
      New data to predict.
  
  sample_weight : array-like of shape (n_samples,), default=None
      The weights for each observation in X. If None, all observations
      are assigned equal weight.
  
      .. deprecated:: 1.3
         The parameter `sample_weight` is deprecated in version 1.3
         and will be removed in 1.5.
  
  Returns
  -------
  labels : ndarray of shape (n_samples,)
      Index of the cluster each sample belongs to.
docstr_tok: ["Predict","the","closest","cluster","each","sample","in","X","belongs","to",".","In","the","vector","quantization","literature",",","`","cluster_centers_","`","is","called","the","code","book","and","each","value","returned","by","`","predict","`","is","the","index","of","the","closest","code","in","the","code","book",".","Parameters","--","--","--","--","--","X",":","{","array-like",",","sparse","matrix","}","of","shape","(","n_samples",",","n_features",")","New","data","to","predict",".","sample_weight",":","array-like","of","shape","(","n_samples",",",")",",","default=None","The","weights","for","each","observation","in","X",".","If","None",",","all","observations","are","assigned","equal","weight",".","..","deprecated",":",":","1.3","The","parameter","`","sample_weight","`","is","deprecated","in","version","1.3","and","will","be","removed","in","1.5",".","Returns","--","--","--","-","labels",":","ndarray","of","shape","(","n_samples",",",")","Index","of","the","cluster","each","sample","belongs","to","."]
code: def predict(self, X, sample_weight="deprecated"):
      """Predict the closest cluster each sample in X belongs to.
  
      In the vector quantization literature, `cluster_centers_` is called
      the code book and each value returned by `predict` is the index of
      the closest code in the code book.
  
      Parameters
      ----------
      X : {array-like, sparse matrix} of shape (n_samples, n_features)
          New data to predict.
  
      sample_weight : array-like of shape (n_samples,), default=None
          The weights for each observation in X. If None, all observations
          are assigned equal weight.
  
          .. deprecated:: 1.3
             The parameter `sample_weight` is deprecated in version 1.3
             and will be removed in 1.5.
  
      Returns
      -------
      labels : ndarray of shape (n_samples,)
          Index of the cluster each sample belongs to.
      """
      check_is_fitted(self)
  
      X = self._check_test_data(X)
      if not (
          isinstance(sample_weight, str)
          and sample_weight == "deprecated"
      ):
          warnings.warn(
              (
                  "'sample_weight' was deprecated in version 1.3 and "
                  "will be removed in 1.5."
              ),
              FutureWarning,
          )
          sample_weight = _check_sample_weight(
              sample_weight, X, dtype=X.dtype
          )
      else:
          sample_weight = _check_sample_weight(None, X, dtype=X.dtype)
  
      labels = _labels_inertia_threadpool_limit(
          X,
          sample_weight,
          self.cluster_centers_,
          n_threads=self._n_threads,
          return_inertia=False,
      )
  
      return labels
  
imports: import warnings
  from abc import ABC, abstractmethod
  from numbers import Integral, Real
  import numpy
  import scipy.sparse
  from ..base import BaseEstimator, ClassNamePrefixFeaturesOutMixin, ClusterMixin, TransformerMixin, _fit_context
  from ..exceptions import ConvergenceWarning
  from ..metrics.pairwise import _euclidean_distances, euclidean_distances
  from ..utils import check_array, check_random_state
  from ..utils._openmp_helpers import _openmp_effective_n_threads
  from ..utils._param_validation import Hidden, Interval, StrOptions, validate_params
  from ..utils.extmath import row_norms, stable_cumsum
  from ..utils.fixes import threadpool_info, threadpool_limits
  from ..utils.sparsefuncs import mean_variance_axis
  from ..utils.sparsefuncs_fast import assign_rows_csr
  from ..utils.validation import _check_sample_weight, _is_arraylike_not_scalar, check_is_fitted
  from ._k_means_common import CHUNK_SIZE, _inertia_dense, _inertia_sparse, _is_same_clustering
  from ._k_means_elkan import elkan_iter_chunked_dense, elkan_iter_chunked_sparse, init_bounds_dense, init_bounds_sparse
  from ._k_means_lloyd import lloyd_iter_chunked_dense, lloyd_iter_chunked_sparse
  from ._k_means_minibatch import _minibatch_update_dense, _minibatch_update_sparse
label_desc: Use image node_id 9 for calling the _BaseKMeans obj's underlying member method code with example usage: obj.predict(X, sample_weight) and returns: labels