class_docstr: !
  @brief Represents self-organized feature map (SOM).
  @details The self-organizing feature map (SOM) method is a powerful tool for the visualization of
           of high-dimensional data. It converts complex, nonlinear statistical relationships between
           high-dimensional data into simple geometric relationships on a low-dimensional display.
  
  @details `ccore` option can be specified in order to control using C++ implementation of pyclustering library. By
            default C++ implementation is on. C++ implementation improves performance of the self-organized feature
            map.
  
  Example:
  @code
      import random
  
      from pyclustering.utils import read_sample
      from pyclustering.nnet.som import som, type_conn, type_init, som_parameters
      from pyclustering.samples.definitions import FCPS_SAMPLES
  
      # read sample 'Lsun' from file
      sample = read_sample(FCPS_SAMPLES.SAMPLE_LSUN)
  
      # create SOM parameters
      parameters = som_parameters()
  
      # create self-organized feature map with size 7x7
      rows = 10  # five rows
      cols = 10  # five columns
      structure = type_conn.grid_four;  # each neuron has max. four neighbors.
      network = som(rows, cols, structure, parameters)
  
      # train network on 'Lsun' sample during 100 epouchs.
      network.train(sample, 100)
  
      # simulate trained network using randomly modified point from input dataset.
      index_point = random.randint(0, len(sample) - 1)
      point = sample[index_point]  # obtain randomly point from data
      point[0] += random.random() * 0.2  # change randomly X-coordinate
      point[1] += random.random() * 0.2  # change randomly Y-coordinate
      index_winner = network.simulate(point)
  
      # check what are objects from input data are much close to randomly modified.
      index_similar_objects = network.capture_objects[index_winner]
  
      # neuron contains information of encoded objects
      print("Point '%s' is similar to objects with indexes '%s'." % (str(point), str(index_similar_objects)))
      print("Coordinates of similar objects:")
      for index in index_similar_objects: print("     Point:", sample[index])
  
      # result visualization:
      # show distance matrix (U-matrix).
      network.show_distance_matrix()
  
      # show density matrix (P-matrix).
      network.show_density_matrix()
  
      # show winner matrix.
      network.show_winner_matrix()
  
      # show self-organized map.
      network.show_network()
  @endcode
  
  There is a visualization of 'Target' sample that was done by the self-organized feature map:
  @image html target_som_processing.png
class_docstr_tok: ["!","@","brief","Represents","self-organized","feature","map","(","SOM",")",".","@","details","The","self-organizing","feature","map","(","SOM",")","method","is","a","powerful","tool","for","the","visualization","of","of","high-dimensional","data",".","It","converts","complex",",","nonlinear","statistical","relationships","between","high-dimensional","data","into","simple","geometric","relationships","on","a","low-dimensional","display",".","@","details","`","ccore","`","option","can","be","specified","in","order","to","control","using","C++","implementation","of","pyclustering","library",".","By","default","C++","implementation","is","on",".","C++","implementation","improves","performance","of","the","self-organized","feature","map",".","Example",":","@","code","import","random","from","pyclustering.utils","import","read_sample","from","pyclustering.nnet.som","import","som",",","type_conn",",","type_init",",","som_parameters","from","pyclustering.samples.definitions","import","FCPS_SAMPLES","#","read","sample","'Lsun","'","from","file","sample","=","read_sample","(","FCPS_SAMPLES.SAMPLE_LSUN",")","#","create","SOM","parameters","parameters","=","som_parameters","(",")","#","create","self-organized","feature","map","with","size","7x7","rows","=","10","#","five","rows","cols","=","10","#","five","columns","structure","=","type_conn.grid_four",";","#","each","neuron","has","max",".","four","neighbors",".","network","=","som","(","rows",",","cols",",","structure",",","parameters",")","#","train","network","on","'Lsun","'","sample","during","100","epouchs",".","network.train","(","sample",",","100",")","#","simulate","trained","network","using","randomly","modified","point","from","input","dataset",".","index_point","=","random.randint","(","0",",","len","(","sample",")","-","1",")","point","=","sample","[","index_point","]","#","obtain","randomly","point","from","data","point","[","0","]","+=","random.random","(",")","*","0.2","#","change","randomly","X-coordinate","point","[","1","]","+=","random.random","(",")","*","0.2","#","change","randomly","Y-coordinate","index_winner","=","network.simulate","(","point",")","#","check","what","are","objects","from","input","data","are","much","close","to","randomly","modified",".","index_similar_objects","=","network.capture_objects","[","index_winner","]","#","neuron","contains","information","of","encoded","objects","print","(","``","Point","'","%","s","'","is","similar","to","objects","with","indexes","'","%","s","'",".","''","%","(","str","(","point",")",",","str","(","index_similar_objects",")",")",")","print","(","``","Coordinates","of","similar","objects",":","''",")","for","index","in","index_similar_objects",":","print","(","``","Point",":","''",",","sample","[","index","]",")","#","result","visualization",":","#","show","distance","matrix","(","U-matrix",")",".","network.show_distance_matrix","(",")","#","show","density","matrix","(","P-matrix",")",".","network.show_density_matrix","(",")","#","show","winner","matrix",".","network.show_winner_matrix","(",")","#","show","self-organized","map",".","network.show_network","(",")","@","endcode","There","is","a","visualization","of","'Target","'","sample","that","was","done","by","the","self-organized","feature","map",":","@","image","html","target_som_processing.png"]
docstr: !
  @brief Shows gray visualization of U-matrix (distance matrix).
  
  @see get_distance_matrix()
docstr_tok: ["!","@","brief","Shows","gray","visualization","of","U-matrix","(","distance","matrix",")",".","@","see","get_distance_matrix","(",")"]
code: def show_distance_matrix(self):
      """!
      @brief Shows gray visualization of U-matrix (distance matrix).
  
      @see get_distance_matrix()
  
      """
      distance_matrix = self.get_distance_matrix()
  
      plt.imshow(
          distance_matrix,
          cmap=plt.get_cmap("hot"),
          interpolation="kaiser",
      )
      plt.title("U-Matrix")
      plt.colorbar()
      plt.show()
  
imports: import math
  import random
  import matplotlib.pyplot
  import pyclustering.core.som_wrapper
  from pyclustering.core.wrapper import ccore_library
  from pyclustering.utils import euclidean_distance_square
  from pyclustering.utils.dimension import dimension_info
  from enum import IntEnum
label_desc: Use image node_id 21 for calling the som obj's underlying member method code with example usage: obj.show_distance_matrix() without return types