class_docstr: !
  @brief Class implements K-Means clustering algorithm.
  @details K-Means clustering aims to partition n observations into k clusters in which each observation belongs to
            the cluster with the nearest mean, serving as a prototype of the cluster. This results in a partitioning
            of the data space into Voronoi cells.
  
  K-Means clustering results depend on initial centers. Algorithm K-Means++ can used for initialization of
  initial centers - see module 'pyclustering.cluster.center_initializer'.
  
  CCORE implementation (C/C++ part of the library) of the algorithm performs parallel processing to ensure maximum
  performance.
  
  Implementation based on the paper @cite inproceedings::kmeans::1.
  
  @image html kmeans_example_clustering.png "Fig. 1. K-Means clustering results. At the left - 'Simple03.data' sample, at the right - 'Lsun.data' sample."
  
  Example #1 - Clustering using K-Means++ for center initialization:
  @code
      from pyclustering.cluster.kmeans import kmeans, kmeans_visualizer
      from pyclustering.cluster.center_initializer import kmeans_plusplus_initializer
      from pyclustering.samples.definitions import FCPS_SAMPLES
      from pyclustering.utils import read_sample
  
      # Load list of points for cluster analysis.
      sample = read_sample(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS)
  
      # Prepare initial centers using K-Means++ method.
      initial_centers = kmeans_plusplus_initializer(sample, 2).initialize()
  
      # Create instance of K-Means algorithm with prepared centers.
      kmeans_instance = kmeans(sample, initial_centers)
  
      # Run cluster analysis and obtain results.
      kmeans_instance.process()
      clusters = kmeans_instance.get_clusters()
      final_centers = kmeans_instance.get_centers()
  
      # Visualize obtained results
      kmeans_visualizer.show_clusters(sample, clusters, final_centers)
  @endcode
  
  Example #2 - Clustering using specific distance metric, for example, Manhattan distance:
  @code
      # prepare input data and initial centers for cluster analysis using K-Means
  
      # create metric that will be used for clustering
      manhattan_metric = distance_metric(type_metric.MANHATTAN)
  
      # create instance of K-Means using specific distance metric:
      kmeans_instance = kmeans(sample, initial_centers, metric=manhattan_metric)
  
      # run cluster analysis and obtain results
      kmeans_instance.process()
      clusters = kmeans_instance.get_clusters()
  @endcode
  
  Implementation based on paper @cite inproceedings::kmeans::1.
  
  @see center_initializer
docstr: !
  @brief Calculates the closest cluster to each point.
  
  @param[in] points (array_like): Points for which closest clusters are calculated.
  
  @return (list) List of closest clusters for each point. Each cluster is denoted by index. Return empty
           collection if 'process()' method was not called.
docstr_tok: ["!","@","brief","Calculates","the","closest","cluster","to","each","point",".","@","param","[","in","]","points","(","array_like",")",":","Points","for","which","closest","clusters","are","calculated",".","@","return","(","list",")","List","of","closest","clusters","for","each","point",".","Each","cluster","is","denoted","by","index",".","Return","empty","collection","if","'process","(",")","'","method","was","not","called","."]
code: def predict(self, points):
      """!
      @brief Calculates the closest cluster to each point.
  
      @param[in] points (array_like): Points for which closest clusters are calculated.
  
      @return (list) List of closest clusters for each point. Each cluster is denoted by index. Return empty
               collection if 'process()' method was not called.
  
      """
  
      nppoints = numpy.array(points)
      if len(self.__clusters) == 0:
          return []
  
      differences = numpy.zeros((len(nppoints), len(self.__centers)))
      for index_point in range(len(nppoints)):
          if self.__metric.get_type() != type_metric.USER_DEFINED:
              differences[index_point] = self.__metric(
                  nppoints[index_point], self.__centers
              )
          else:
              differences[index_point] = [
                  self.__metric(nppoints[index_point], center)
                  for center in self.__centers
              ]
  
      return numpy.argmin(differences, axis=1)
  
imports: import copy
  import numpy
  import matplotlib.pyplot
  import matplotlib.animation
  import pyclustering.core.kmeans_wrapper
  from pyclustering.core.wrapper import ccore_library
  from pyclustering.core.metric_wrapper import metric_wrapper
  from pyclustering.cluster.encoder import type_encoding
  from pyclustering.cluster import cluster_visualizer
  from pyclustering.utils.metric import distance_metric, type_metric
label_desc: Use image node_id 5 for calling the kmeans obj's underlying member method code with example usage: obj.predict(points) and returns: numpy, list