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 Performs cluster analysis using python code.
docstr_tok: ["!","@","brief","Performs","cluster","analysis","using","python","code","."]
code: def __process_by_python(self):
      """!
      @brief Performs cluster analysis using python code.
  
      """
  
      maximum_change = float("inf")
      iteration = 0
  
      if self.__observer is not None:
          initial_clusters = self.__update_clusters()
          self.__observer.notify(
              initial_clusters, self.__centers.tolist()
          )
  
      while (
          maximum_change > self.__tolerance
          and iteration < self.__itermax
      ):
          self.__clusters = self.__update_clusters()
          updated_centers = (
              self.__update_centers()
          )  # changes should be calculated before assignment
  
          if self.__observer is not None:
              self.__observer.notify(
                  self.__clusters, updated_centers.tolist()
              )
  
          maximum_change = self.__calculate_changes(updated_centers)
  
          self.__centers = (
              updated_centers  # assign center after change calculation
          )
          iteration += 1
  
      self.__calculate_total_wce()
  
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 4 for calling the kmeans obj's underlying member method code with example usage: obj.__process_by_python() without return types