class_docstr: !
  @brief Class represents the clustering algorithm BIRCH (Balanced Iterative Reducing and Clustering using
          Hierarchies).
  
  @details BIRCH is suitable for large databases. The algorithm incrementally and dynamically clusters
            incoming multi-dimensional metric data points using the concepts of Clustering Feature and CF tree.
            A Clustering Feature is a triple summarizing the information that is maintained about a cluster.
            The Clustering Feature vector is defined as a triple:
            [CF=\left ( N, \overrightarrow{LS}, SS 
  ight )]
  
  Example how to extract clusters from 'OldFaithful' sample using BIRCH algorithm:
  @code
      from pyclustering.cluster.birch import birch
      from pyclustering.cluster import cluster_visualizer
      from pyclustering.utils import read_sample
      from pyclustering.samples.definitions import FAMOUS_SAMPLES
  
      # Sample for cluster analysis (represented by list)
      sample = read_sample(FAMOUS_SAMPLES.SAMPLE_OLD_FAITHFUL)
  
      # Create BIRCH algorithm
      birch_instance = birch(sample, 2, diameter=3.0)
  
      # Cluster analysis
      birch_instance.process()
  
      # Obtain results of clustering
      clusters = birch_instance.get_clusters()
  
      # Visualize allocated clusters
      visualizer = cluster_visualizer()
      visualizer.append_clusters(clusters, sample)
      visualizer.show()
  @endcode
  
  Here is the clustering result produced by BIRCH algorithm:
  @image html birch_clustering_old_faithful.png "Fig. 1. BIRCH clustering - sample 'OldFaithful'."
  
  Methods 'get_cf_entries' and 'get_cf_clusters' can be used to obtain information how does an input data is
  encoded. Here is an example how the encoding information can be extracted and visualized:
  @code
      from pyclustering.cluster.birch import birch
      from pyclustering.cluster import cluster_visualizer
      from pyclustering.utils import read_sample
      from pyclustering.samples.definitions import FCPS_SAMPLES
  
      # Sample 'Lsun' for cluster analysis (represented by list of points)
      sample = read_sample(FCPS_SAMPLES.SAMPLE_LSUN)
  
      # Create BIRCH algorithm
      birch_instance = birch(sample, 3, diameter=0.5)
  
      # Cluster analysis
      birch_instance.process()
  
      # Obtain results of clustering
      clusters = birch_instance.get_clusters()
  
      # Obtain information how does the 'Lsun' sample is encoded in the CF-tree.
      cf_entries = birch_instance.get_cf_entries()
      cf_clusters = birch_instance.get_cf_cluster()
  
      cf_centroids = [entry.get_centroid() for entry in cf_entries]
  
      # Visualize allocated clusters
      visualizer = cluster_visualizer(2, 2, titles=["Encoded data by CF-entries", "Data clusters"])
      visualizer.append_clusters(cf_clusters, cf_centroids, canvas=0)
      visualizer.append_clusters(clusters, sample, canvas=1)
      visualizer.show()
  @endcode
  
  Here is the clustering result produced by BIRCH algorithm:
  @image html birch_cf_encoding_lsun.png "Fig. 2. CF-tree encoding and BIRCH clustering of 'Lsun' sample."
class_docstr_tok: ["!","@","brief","Class","represents","the","clustering","algorithm","BIRCH","(","Balanced","Iterative","Reducing","and","Clustering","using","Hierarchies",")",".","@","details","BIRCH","is","suitable","for","large","databases",".","The","algorithm","incrementally","and","dynamically","clusters","incoming","multi-dimensional","metric","data","points","using","the","concepts","of","Clustering","Feature","and","CF","tree",".","A","Clustering","Feature","is","a","triple","summarizing","the","information","that","is","maintained","about","a","cluster",".","The","Clustering","Feature","vector","is","defined","as","a","triple",":","[","CF=\\left","(","N",",","\\overrightarrow","{","LS","}",",","SS","ight",")","]","Example","how","to","extract","clusters","from","'OldFaithful","'","sample","using","BIRCH","algorithm",":","@","code","from","pyclustering.cluster.birch","import","birch","from","pyclustering.cluster","import","cluster_visualizer","from","pyclustering.utils","import","read_sample","from","pyclustering.samples.definitions","import","FAMOUS_SAMPLES","#","Sample","for","cluster","analysis","(","represented","by","list",")","sample","=","read_sample","(","FAMOUS_SAMPLES.SAMPLE_OLD_FAITHFUL",")","#","Create","BIRCH","algorithm","birch_instance","=","birch","(","sample",",","2",",","diameter=3.0",")","#","Cluster","analysis","birch_instance.process","(",")","#","Obtain","results","of","clustering","clusters","=","birch_instance.get_clusters","(",")","#","Visualize","allocated","clusters","visualizer","=","cluster_visualizer","(",")","visualizer.append_clusters","(","clusters",",","sample",")","visualizer.show","(",")","@","endcode","Here","is","the","clustering","result","produced","by","BIRCH","algorithm",":","@","image","html","birch_clustering_old_faithful.png","``","Fig",".","1",".","BIRCH","clustering","-","sample","'OldFaithful","'",".","''","Methods","'get_cf_entries","'","and","'get_cf_clusters","'","can","be","used","to","obtain","information","how","does","an","input","data","is","encoded",".","Here","is","an","example","how","the","encoding","information","can","be","extracted","and","visualized",":","@","code","from","pyclustering.cluster.birch","import","birch","from","pyclustering.cluster","import","cluster_visualizer","from","pyclustering.utils","import","read_sample","from","pyclustering.samples.definitions","import","FCPS_SAMPLES","#","Sample","'Lsun","'","for","cluster","analysis","(","represented","by","list","of","points",")","sample","=","read_sample","(","FCPS_SAMPLES.SAMPLE_LSUN",")","#","Create","BIRCH","algorithm","birch_instance","=","birch","(","sample",",","3",",","diameter=0.5",")","#","Cluster","analysis","birch_instance.process","(",")","#","Obtain","results","of","clustering","clusters","=","birch_instance.get_clusters","(",")","#","Obtain","information","how","does","the","'Lsun","'","sample","is","encoded","in","the","CF-tree",".","cf_entries","=","birch_instance.get_cf_entries","(",")","cf_clusters","=","birch_instance.get_cf_cluster","(",")","cf_centroids","=","[","entry.get_centroid","(",")","for","entry","in","cf_entries","]","#","Visualize","allocated","clusters","visualizer","=","cluster_visualizer","(","2",",","2",",","titles=","[","``","Encoded","data","by","CF-entries","''",",","``","Data","clusters","''","]",")","visualizer.append_clusters","(","cf_clusters",",","cf_centroids",",","canvas=0",")","visualizer.append_clusters","(","clusters",",","sample",",","canvas=1",")","visualizer.show","(",")","@","endcode","Here","is","the","clustering","result","produced","by","BIRCH","algorithm",":","@","image","html","birch_cf_encoding_lsun.png","``","Fig",".","2",".","CF-tree","encoding","and","BIRCH","clustering","of","'Lsun","'","sample",".","''"]
docstr: !
  @brief Constructor of clustering algorithm BIRCH.
  
  @param[in] data (list): An input data represented as a list of points (objects) where each point is be represented by list of coordinates.
  @param[in] number_clusters (uint): Amount of clusters that should be allocated.
  @param[in] branching_factor (uint): Maximum number of successor that might be contained by each non-leaf node in CF-Tree.
  @param[in] max_node_entries (uint): Maximum number of entries that might be contained by each leaf node in CF-Tree.
  @param[in] diameter (double): CF-entry diameter that used for CF-Tree construction, it might be increase if 'entry_size_limit' is exceeded.
  @param[in] type_measurement (measurement_type): Type measurement used for calculation distance metrics.
  @param[in] entry_size_limit (uint): Maximum number of entries that can be stored in CF-Tree, if it is exceeded
              during creation then the 'diameter' is increased and CF-Tree is rebuilt.
  @param[in] diameter_multiplier (double): Multiplier that is used for increasing diameter when 'entry_size_limit' is exceeded.
  @param[in] ccore (bool): If True than C++ part of the library is used for processing.
docstr_tok: ["!","@","brief","Constructor","of","clustering","algorithm","BIRCH",".","@","param","[","in","]","data","(","list",")",":","An","input","data","represented","as","a","list","of","points","(","objects",")","where","each","point","is","be","represented","by","list","of","coordinates",".","@","param","[","in","]","number_clusters","(","uint",")",":","Amount","of","clusters","that","should","be","allocated",".","@","param","[","in","]","branching_factor","(","uint",")",":","Maximum","number","of","successor","that","might","be","contained","by","each","non-leaf","node","in","CF-Tree",".","@","param","[","in","]","max_node_entries","(","uint",")",":","Maximum","number","of","entries","that","might","be","contained","by","each","leaf","node","in","CF-Tree",".","@","param","[","in","]","diameter","(","double",")",":","CF-entry","diameter","that","used","for","CF-Tree","construction",",","it","might","be","increase","if","'entry_size_limit","'","is","exceeded",".","@","param","[","in","]","type_measurement","(","measurement_type",")",":","Type","measurement","used","for","calculation","distance","metrics",".","@","param","[","in","]","entry_size_limit","(","uint",")",":","Maximum","number","of","entries","that","can","be","stored","in","CF-Tree",",","if","it","is","exceeded","during","creation","then","the","'diameter","'","is","increased","and","CF-Tree","is","rebuilt",".","@","param","[","in","]","diameter_multiplier","(","double",")",":","Multiplier","that","is","used","for","increasing","diameter","when","'entry_size_limit","'","is","exceeded",".","@","param","[","in","]","ccore","(","bool",")",":","If","True","than","C++","part","of","the","library","is","used","for","processing","."]
code: def __init__(
      self,
      data,
      number_clusters,
      branching_factor=50,
      max_node_entries=200,
      diameter=0.5,
      type_measurement=measurement_type.CENTROID_EUCLIDEAN_DISTANCE,
      entry_size_limit=500,
      diameter_multiplier=1.5,
      ccore=True,
  ):
      """!
      @brief Constructor of clustering algorithm BIRCH.
  
      @param[in] data (list): An input data represented as a list of points (objects) where each point is be represented by list of coordinates.
      @param[in] number_clusters (uint): Amount of clusters that should be allocated.
      @param[in] branching_factor (uint): Maximum number of successor that might be contained by each non-leaf node in CF-Tree.
      @param[in] max_node_entries (uint): Maximum number of entries that might be contained by each leaf node in CF-Tree.
      @param[in] diameter (double): CF-entry diameter that used for CF-Tree construction, it might be increase if 'entry_size_limit' is exceeded.
      @param[in] type_measurement (measurement_type): Type measurement used for calculation distance metrics.
      @param[in] entry_size_limit (uint): Maximum number of entries that can be stored in CF-Tree, if it is exceeded
                  during creation then the 'diameter' is increased and CF-Tree is rebuilt.
      @param[in] diameter_multiplier (double): Multiplier that is used for increasing diameter when 'entry_size_limit' is exceeded.
      @param[in] ccore (bool): If True than C++ part of the library is used for processing.
  
      """
  
      self.__pointer_data = data
      self.__number_clusters = number_clusters
  
      self.__measurement_type = type_measurement
      self.__entry_size_limit = entry_size_limit
      self.__diameter_multiplier = diameter_multiplier
      self.__ccore = ccore
  
      self.__verify_arguments()
  
      self.__features = None
      self.__tree = cftree(
          branching_factor, max_node_entries, diameter, type_measurement
      )
  
      self.__clusters = []
      self.__cf_clusters = []
  
file_path: pyclustering/pyclustering/cluster/birch.py
imports: import numpy
  from pyclustering.cluster.agglomerative import agglomerative, type_link
  from pyclustering.cluster.encoder import cluster_encoder, type_encoding
  from pyclustering.container.cftree import cftree, measurement_type
label_desc: Use image node_id 1 to create a new birch object  with example: obj = birch(data, number_clusters, branching_factor, max_node_entries, diameter, type_measurement, entry_size_limit, diameter_multiplier, ccore)