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 Constructor of clustering algorithm K-Medians.
  
  @param[in] data (list): Input data that is presented as list of points (objects), each point should be represented by list or tuple.
  @param[in] initial_medians (list): Initial coordinates of medians of clusters that are represented by list: [center1, center2, ...].
  @param[in] tolerance (double): Stop condition: if maximum value of change of centers of clusters is less than tolerance than algorithm will stop processing
  @param[in] ccore (bool): Defines should be CCORE library (C++ pyclustering library) used instead of Python code or not.
  @param[in] **kwargs: Arbitrary keyword arguments (available arguments: 'metric', 'itermax').
  
  <b>Keyword Args:</b><br>
      - metric (distance_metric): Metric that is used for distance calculation between two points.
      - itermax (uint): Maximum number of iterations for cluster analysis.
docstr_tok: ["!","@","brief","Constructor","of","clustering","algorithm","K-Medians",".","@","param","[","in","]","data","(","list",")",":","Input","data","that","is","presented","as","list","of","points","(","objects",")",",","each","point","should","be","represented","by","list","or","tuple",".","@","param","[","in","]","initial_medians","(","list",")",":","Initial","coordinates","of","medians","of","clusters","that","are","represented","by","list",":","[","center1",",","center2",",","...","]",".","@","param","[","in","]","tolerance","(","double",")",":","Stop","condition",":","if","maximum","value","of","change","of","centers","of","clusters","is","less","than","tolerance","than","algorithm","will","stop","processing","@","param","[","in","]","ccore","(","bool",")",":","Defines","should","be","CCORE","library","(","C++","pyclustering","library",")","used","instead","of","Python","code","or","not",".","@","param","[","in","]","*","*","kwargs",":","Arbitrary","keyword","arguments","(","available","arguments",":","'metric","'",",","'itermax","'",")",".","<","b",">","Keyword","Args",":","<","\/b",">","<","br",">","-","metric","(","distance_metric",")",":","Metric","that","is","used","for","distance","calculation","between","two","points",".","-","itermax","(","uint",")",":","Maximum","number","of","iterations","for","cluster","analysis","."]
code: def __init__(
      self, data, initial_medians, tolerance=0.001, ccore=True, **kwargs
  ):
      """!
      @brief Constructor of clustering algorithm K-Medians.
  
      @param[in] data (list): Input data that is presented as list of points (objects), each point should be represented by list or tuple.
      @param[in] initial_medians (list): Initial coordinates of medians of clusters that are represented by list: [center1, center2, ...].
      @param[in] tolerance (double): Stop condition: if maximum value of change of centers of clusters is less than tolerance than algorithm will stop processing
      @param[in] ccore (bool): Defines should be CCORE library (C++ pyclustering library) used instead of Python code or not.
      @param[in] **kwargs: Arbitrary keyword arguments (available arguments: 'metric', 'itermax').
  
      <b>Keyword Args:</b><br>
          - metric (distance_metric): Metric that is used for distance calculation between two points.
          - itermax (uint): Maximum number of iterations for cluster analysis.
  
      """
      self.__pointer_data = numpy.array(data)
      self.__clusters = []
      self.__medians = numpy.array(initial_medians)
      self.__tolerance = tolerance
      self.__total_wce = 0
  
      self.__itermax = kwargs.get("itermax", 100)
      self.__metric = kwargs.get(
          "metric", distance_metric(type_metric.EUCLIDEAN_SQUARE)
      )
      if self.__metric is None:
          self.__metric = distance_metric(type_metric.EUCLIDEAN_SQUARE)
  
      self.__ccore = (
          ccore and self.__metric.get_type() != type_metric.USER_DEFINED
      )
      if self.__ccore:
          self.__ccore = ccore_library.workable()
  
      self.__verify_arguments()
  
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 1 to create a new kmedians object  with example: obj = kmedians(data, initial_medians, tolerance, ccore)