class_docstr: !
  @brief Class represents clustering algorithm K-Medians.
  @details The algorithm is less sensitive to outliers than K-Means. Medians are calculated instead of centroids.
  
  Example:
  @code
      from pyclustering.cluster.kmedians import kmedians
      from pyclustering.cluster import cluster_visualizer
      from pyclustering.utils import read_sample
      from pyclustering.samples.definitions import FCPS_SAMPLES
  
      # Load list of points for cluster analysis.
      sample = read_sample(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS)
  
      # Create instance of K-Medians algorithm.
      initial_medians = [[0.0, 0.1], [2.5, 0.7]]
      kmedians_instance = kmedians(sample, initial_medians)
  
      # Run cluster analysis and obtain results.
      kmedians_instance.process()
      clusters = kmedians_instance.get_clusters()
      medians = kmedians_instance.get_medians()
  
      # Visualize clustering results.
      visualizer = cluster_visualizer()
      visualizer.append_clusters(clusters, sample)
      visualizer.append_cluster(initial_medians, marker='*', markersize=10)
      visualizer.append_cluster(medians, marker='*', markersize=10)
      visualizer.show()
  @endcode
class_docstr_tok: ["!","@","brief","Class","represents","clustering","algorithm","K-Medians",".","@","details","The","algorithm","is","less","sensitive","to","outliers","than","K-Means",".","Medians","are","calculated","instead","of","centroids",".","Example",":","@","code","from","pyclustering.cluster.kmedians","import","kmedians","from","pyclustering.cluster","import","cluster_visualizer","from","pyclustering.utils","import","read_sample","from","pyclustering.samples.definitions","import","FCPS_SAMPLES","#","Load","list","of","points","for","cluster","analysis",".","sample","=","read_sample","(","FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS",")","#","Create","instance","of","K-Medians","algorithm",".","initial_medians","=","[","[","0.0",",","0.1","]",",","[","2.5",",","0.7","]","]","kmedians_instance","=","kmedians","(","sample",",","initial_medians",")","#","Run","cluster","analysis","and","obtain","results",".","kmedians_instance.process","(",")","clusters","=","kmedians_instance.get_clusters","(",")","medians","=","kmedians_instance.get_medians","(",")","#","Visualize","clustering","results",".","visualizer","=","cluster_visualizer","(",")","visualizer.append_clusters","(","clusters",",","sample",")","visualizer.append_cluster","(","initial_medians",",","marker=","'","*","'",",","markersize=10",")","visualizer.append_cluster","(","medians",",","marker=","'","*","'",",","markersize=10",")","visualizer.show","(",")","@","endcode"]
docstr: !
  @brief Calculate medians of clusters in line with contained objects.
  
  @return (list) list of medians for current number of clusters.
docstr_tok: ["!","@","brief","Calculate","medians","of","clusters","in","line","with","contained","objects",".","@","return","(","list",")","list","of","medians","for","current","number","of","clusters","."]
code: def __update_medians(self):
      """!
      @brief Calculate medians of clusters in line with contained objects.
  
      @return (list) list of medians for current number of clusters.
  
      """
  
      medians = [[] for i in range(len(self.__clusters))]
  
      for index in range(len(self.__clusters)):
          medians[index] = [
              0.0 for i in range(len(self.__pointer_data[0]))
          ]
          length_cluster = len(self.__clusters[index])
  
          for index_dimension in range(len(self.__pointer_data[0])):
              sorted_cluster = sorted(
                  self.__clusters[index],
                  key=lambda x: self.__pointer_data[x][index_dimension],
              )
  
              relative_index_median = int(
                  math.floor((length_cluster - 1) / 2)
              )
              index_median = sorted_cluster[relative_index_median]
  
              if (length_cluster % 2) == 0:
                  index_median_second = sorted_cluster[
                      relative_index_median + 1
                  ]
                  medians[index][index_dimension] = (
                      self.__pointer_data[index_median][index_dimension]
                      + self.__pointer_data[index_median_second][
                          index_dimension
                      ]
                  ) / 2.0
  
              else:
                  medians[index][index_dimension] = self.__pointer_data[
                      index_median
                  ][index_dimension]
  
      return medians
  
file_path: pyclustering/pyclustering/cluster/kmedians.py
imports: import math
  import numpy
  from pyclustering.cluster.encoder import type_encoding
  from pyclustering.utils.metric import distance_metric, type_metric
  import pyclustering.core.kmedians_wrapper
  from pyclustering.core.wrapper import ccore_library
  from pyclustering.core.metric_wrapper import metric_wrapper
label_desc: Use image node_id 11 for calling the kmedians obj's underlying member method code with example usage: obj.__update_medians() and returns: medians