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 Returns sum of metric errors that depends on metric that was used for clustering (by default SSE - Sum of Squared Errors).
  @details Sum of metric errors is calculated using distance between point and its center:
           [error=\sum_{i=0}^{N}distance(x_{i}-center(x_{i}))]
  
  @see process()
  @see get_clusters()
docstr_tok: ["!","@","brief","Returns","sum","of","metric","errors","that","depends","on","metric","that","was","used","for","clustering","(","by","default","SSE","-","Sum","of","Squared","Errors",")",".","@","details","Sum","of","metric","errors","is","calculated","using","distance","between","point","and","its","center",":","[","error=\\sum_","{","i=0","}","^","{","N","}","distance","(","x_","{","i","}","-center","(","x_","{","i","}",")",")","]","@","see","process","(",")","@","see","get_clusters","(",")"]
code: def get_total_wce(self):
      """!
      @brief Returns sum of metric errors that depends on metric that was used for clustering (by default SSE - Sum of Squared Errors).
      @details Sum of metric errors is calculated using distance between point and its center:
               \f[error=\sum_{i=0}^{N}distance(x_{i}-center(x_{i}))\f]
  
      @see process()
      @see get_clusters()
  
      """
  
      return self.__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 8 for calling the kmeans obj's underlying member method code with example usage: obj.get_total_wce() and returns: self