class_docstr: Class for training and visualizing a self-organizing map.
  
  Attributes:
  
      codebook     The codebook of the self-organizing map.
  
      bmus         The BMUs corresponding to the data points.
  
  :param n_columns: The number of columns in the map.
  :type n_columns: int.
  :param n_rows: The number of rows in the map.
  :type n_rows: int.
  :param initialcodebook: Optional parameter to start the training with a
                          given codebook.
  :type initialcodebook: 2D numpy.array of float32.
  :param kerneltype: Optional parameter to specify which kernel to use:
  
                         * 0: dense CPU kernel (default)
                         * 1: dense GPU kernel (if compiled with it)
  :type kerneltype: int.
  :param maptype: Optional parameter to specify the map topology:
  
                         * "planar": Planar map (default)
                         * "toroid": Toroid map
  :type maptype: str.
  :param gridtype: Optional parameter to specify the grid form of the nodes:
  
                         * "rectangular": rectangular neurons (default)
                         * "hexagonal": hexagonal neurons
  :type gridtype: str.
  :param compactsupport: Optional parameter to cut off map updates beyond the
                         training radius with the Gaussian neighborhood.
                         Default: True.
  :type compactsupport: bool.
  :param neighborhood: Optional parameter to specify the neighborhood:
  
                         * "gaussian": Gaussian neighborhood (default)
                         * "bubble": bubble neighborhood function
  :type neighborhood: str.
  :param vect_distance: Optional parameter to specify the vector distance function:
  
                         * "euclidean": Euclidean (default)
                         * "norm-inf": infinite norm (max absolute distance among components)
                         * "norm-p": p-th root of sum of absolute differences ^ p (only supported by kerneltype 0)
  :type vect_distance: str.
  :param std_coeff: Optional parameter to set the coefficient in the Gaussian
                    neighborhood function exp(-||x-y||^2/(2*(coeff*radius)^2))
                    Default: 0.5
  :type std_coeff: float.
  :param initialization: Optional parameter to specify the initalization:
  
                         * "random": random weights in the codebook
                         * "pca": codebook is initialized from the first
                           subspace spanned by the first two eigenvectors of
                           the correlation matrix
  :type initialization: str.
  :param verbose: Optional parameter to specify verbosity (0, 1, or 2).
  :type verbose: int.
class_docstr_tok: ["Class","for","training","and","visualizing","a","self-organizing","map",".","Attributes",":","codebook","The","codebook","of","the","self-organizing","map",".","bmus","The","BMUs","corresponding","to","the","data","points",".",":","param","n_columns",":","The","number","of","columns","in","the","map",".",":","type","n_columns",":","int",".",":","param","n_rows",":","The","number","of","rows","in","the","map",".",":","type","n_rows",":","int",".",":","param","initialcodebook",":","Optional","parameter","to","start","the","training","with","a","given","codebook",".",":","type","initialcodebook",":","2D","numpy.array","of","float32",".",":","param","kerneltype",":","Optional","parameter","to","specify","which","kernel","to","use",":","*","0",":","dense","CPU","kernel","(","default",")","*","1",":","dense","GPU","kernel","(","if","compiled","with","it",")",":","type","kerneltype",":","int",".",":","param","maptype",":","Optional","parameter","to","specify","the","map","topology",":","*","``","planar","''",":","Planar","map","(","default",")","*","``","toroid","''",":","Toroid","map",":","type","maptype",":","str",".",":","param","gridtype",":","Optional","parameter","to","specify","the","grid","form","of","the","nodes",":","*","``","rectangular","''",":","rectangular","neurons","(","default",")","*","``","hexagonal","''",":","hexagonal","neurons",":","type","gridtype",":","str",".",":","param","compactsupport",":","Optional","parameter","to","cut","off","map","updates","beyond","the","training","radius","with","the","Gaussian","neighborhood",".","Default",":","True",".",":","type","compactsupport",":","bool",".",":","param","neighborhood",":","Optional","parameter","to","specify","the","neighborhood",":","*","``","gaussian","''",":","Gaussian","neighborhood","(","default",")","*","``","bubble","''",":","bubble","neighborhood","function",":","type","neighborhood",":","str",".",":","param","vect_distance",":","Optional","parameter","to","specify","the","vector","distance","function",":","*","``","euclidean","''",":","Euclidean","(","default",")","*","``","norm-inf","''",":","infinite","norm","(","max","absolute","distance","among","components",")","*","``","norm-p","''",":","p-th","root","of","sum","of","absolute","differences","^","p","(","only","supported","by","kerneltype","0",")",":","type","vect_distance",":","str",".",":","param","std_coeff",":","Optional","parameter","to","set","the","coefficient","in","the","Gaussian","neighborhood","function","exp","(","-||x-y||^2\/","(","2","*","(","coeff","*","radius",")","^2",")",")","Default",":","0.5",":","type","std_coeff",":","float",".",":","param","initialization",":","Optional","parameter","to","specify","the","initalization",":","*","``","random","''",":","random","weights","in","the","codebook","*","``","pca","''",":","codebook","is","initialized","from","the","first","subspace","spanned","by","the","first","two","eigenvectors","of","the","correlation","matrix",":","type","initialization",":","str",".",":","param","verbose",":","Optional","parameter","to","specify","verbosity","(","0",",","1",",","or","2",")",".",":","type","verbose",":","int","."]
docstr: Plot the U-matrix of the trained map.
  
  :param figsize: Optional parameter to specify the size of the figure.
  :type figsize: (int, int)
  :param colormap: Optional parameter to specify the color map to be
                   used.
  :type colormap: matplotlib.colors.Colormap
  :param colorbar: Optional parameter to include a colormap as legend.
  :type colorbar: bool.
  :param bestmatches: Optional parameter to plot best matching units.
  :type bestmatches: bool.
  :param bestmatchcolors: Optional parameter to specify the color of each
                          best matching unit.
  :type bestmatchcolors: list of int.
  :param labels: Optional parameter to specify the label of each point.
  :type labels: list of str.
  :param zoom: Optional parameter to zoom into a region on the map. The
               first two coordinates of the tuple are the row limits, the
               second tuple contains the column limits.
  :type zoom: ((int, int), (int, int))
  :param filename: If specified, the plot will not be shown but saved to
                   this file.
  :type filename: str.
docstr_tok: ["Plot","the","U-matrix","of","the","trained","map",".",":","param","figsize",":","Optional","parameter","to","specify","the","size","of","the","figure",".",":","type","figsize",":","(","int",",","int",")",":","param","colormap",":","Optional","parameter","to","specify","the","color","map","to","be","used",".",":","type","colormap",":","matplotlib.colors.Colormap",":","param","colorbar",":","Optional","parameter","to","include","a","colormap","as","legend",".",":","type","colorbar",":","bool",".",":","param","bestmatches",":","Optional","parameter","to","plot","best","matching","units",".",":","type","bestmatches",":","bool",".",":","param","bestmatchcolors",":","Optional","parameter","to","specify","the","color","of","each","best","matching","unit",".",":","type","bestmatchcolors",":","list","of","int",".",":","param","labels",":","Optional","parameter","to","specify","the","label","of","each","point",".",":","type","labels",":","list","of","str",".",":","param","zoom",":","Optional","parameter","to","zoom","into","a","region","on","the","map",".","The","first","two","coordinates","of","the","tuple","are","the","row","limits",",","the","second","tuple","contains","the","column","limits",".",":","type","zoom",":","(","(","int",",","int",")",",","(","int",",","int",")",")",":","param","filename",":","If","specified",",","the","plot","will","not","be","shown","but","saved","to","this","file",".",":","type","filename",":","str","."]
code: def view_umatrix(
      self,
      figsize=None,
      colormap=cm.Spectral_r,
      colorbar=False,
      bestmatches=False,
      bestmatchcolors=None,
      labels=None,
      zoom=None,
      filename=None,
  ):
      """Plot the U-matrix of the trained map.
  
      :param figsize: Optional parameter to specify the size of the figure.
      :type figsize: (int, int)
      :param colormap: Optional parameter to specify the color map to be
                       used.
      :type colormap: matplotlib.colors.Colormap
      :param colorbar: Optional parameter to include a colormap as legend.
      :type colorbar: bool.
      :param bestmatches: Optional parameter to plot best matching units.
      :type bestmatches: bool.
      :param bestmatchcolors: Optional parameter to specify the color of each
                              best matching unit.
      :type bestmatchcolors: list of int.
      :param labels: Optional parameter to specify the label of each point.
      :type labels: list of str.
      :param zoom: Optional parameter to zoom into a region on the map. The
                   first two coordinates of the tuple are the row limits, the
                   second tuple contains the column limits.
      :type zoom: ((int, int), (int, int))
      :param filename: If specified, the plot will not be shown but saved to
                       this file.
      :type filename: str.
      """
      if self.umatrix is None:
          raise Exception(
              "The U-matrix is not available. Either train a map"
              " or load a U-matrix from a file"
          )
      return self._view_matrix(
          self.umatrix,
          figsize,
          colormap,
          colorbar,
          bestmatches,
          bestmatchcolors,
          labels,
          zoom,
          filename,
      )
  
imports: from __future__ import division, print_function
  import sys
  import matplotlib.cm
  import matplotlib.pyplot
  import matplotlib.collections
  import numpy
  from scipy.spatial.distance import cdist
label_desc: Use image node_id 8 for calling the Somoclu obj's underlying member method code with example usage: obj.view_umatrix(figsize, colormap, colorbar, bestmatches, bestmatchcolors, labels, zoom, filename) and returns: self