class_docstr: Perform HDBSCAN clustering from vector array or distance matrix.
  
  HDBSCAN - Hierarchical Density-Based Spatial Clustering of Applications
  with Noise. Performs DBSCAN over varying epsilon values and integrates
  the result to find a clustering that gives the best stability over epsilon.
  This allows HDBSCAN to find clusters of varying densities (unlike DBSCAN),
  and be more robust to parameter selection.
  
  Parameters
  ----------
  min_cluster_size : int, optional (default=5)
      The minimum size of clusters; single linkage splits that contain
      fewer points than this will be considered points "falling out" of a
      cluster rather than a cluster splitting into two new clusters.
  
  min_samples : int, optional (default=None)
      The number of samples in a neighbourhood for a point to be
      considered a core point.
  
  metric : string, or callable, optional (default='euclidean')
      The metric to use when calculating distance between instances in a
      feature array. If metric is a string or callable, it must be one of
      the options allowed by metrics.pairwise.pairwise_distances for its
      metric parameter.
      If metric is "precomputed", X is assumed to be a distance matrix and
      must be square.
  
  p : int, optional (default=None)
      p value to use if using the minkowski metric.
  
  alpha : float, optional (default=1.0)
      A distance scaling parameter as used in robust single linkage.
      See [3]_ for more information.
  
  cluster_selection_epsilon: float, optional (default=0.0)
              A distance threshold. Clusters below this value will be merged.
      See [5]_ for more information.
  
  algorithm : string, optional (default='best')
      Exactly which algorithm to use; hdbscan has variants specialised
      for different characteristics of the data. By default this is set
      to ``best`` which chooses the "best" algorithm given the nature of
      the data. You can force other options if you believe you know
      better. Options are:
          * ``best``
          * ``generic``
          * ``prims_kdtree``
          * ``prims_balltree``
          * ``boruvka_kdtree``
          * ``boruvka_balltree``
  
  leaf_size: int, optional (default=40)
      If using a space tree algorithm (kdtree, or balltree) the number
      of points ina leaf node of the tree. This does not alter the
      resulting clustering, but may have an effect on the runtime
      of the algorithm.
  
  memory : Instance of joblib.Memory or string (optional)
      Used to cache the output of the computation of the tree.
      By default, no caching is done. If a string is given, it is the
      path to the caching directory.
  
  approx_min_span_tree : bool, optional (default=True)
      Whether to accept an only approximate minimum spanning tree.
      For some algorithms this can provide a significant speedup, but
      the resulting clustering may be of marginally lower quality.
      If you are willing to sacrifice speed for correctness you may want
      to explore this; in general this should be left at the default True.
  
  gen_min_span_tree: bool, optional (default=False)
      Whether to generate the minimum spanning tree with regard
      to mutual reachability distance for later analysis.
  
  core_dist_n_jobs : int, optional (default=4)
      Number of parallel jobs to run in core distance computations (if
      supported by the specific algorithm). For ``core_dist_n_jobs``
      below -1, (n_cpus + 1 + core_dist_n_jobs) are used.
  
  cluster_selection_method : string, optional (default='eom')
      The method used to select clusters from the condensed tree. The
      standard approach for HDBSCAN* is to use an Excess of Mass algorithm
      to find the most persistent clusters. Alternatively you can instead
      select the clusters at the leaves of the tree -- this provides the
      most fine grained and homogeneous clusters. Options are:
          * ``eom``
          * ``leaf``
  
  allow_single_cluster : bool, optional (default=False)
      By default HDBSCAN* will not produce a single cluster, setting this
      to True will override this and allow single cluster results in
      the case that you feel this is a valid result for your dataset.
  
  prediction_data : boolean, optional
      Whether to generate extra cached data for predicting labels or
      membership vectors for new unseen points later. If you wish to
      persist the clustering object for later re-use you probably want
      to set this to True.
      (default False)
  
  match_reference_implementation : bool, optional (default=False)
      There exist some interpretational differences between this
      HDBSCAN* implementation and the original authors reference
      implementation in Java. This can result in very minor differences
      in clustering results. Setting this flag to True will, at a some
      performance cost, ensure that the clustering results match the
      reference implementation.
  
  **kwargs : optional
      Arguments passed to the distance metric
  
  Attributes
  ----------
  labels_ : ndarray, shape (n_samples, )
      Cluster labels for each point in the dataset given to fit().
      Noisy samples are given the label -1.
  
  probabilities_ : ndarray, shape (n_samples, )
      The strength with which each sample is a member of its assigned
      cluster. Noise points have probability zero; points in clusters
      have values assigned proportional to the degree that they
      persist as part of the cluster.
  
  cluster_persistence_ : ndarray, shape (n_clusters, )
      A score of how persistent each cluster is. A score of 1.0 represents
      a perfectly stable cluster that persists over all distance scales,
      while a score of 0.0 represents a perfectly ephemeral cluster. These
      scores can be guage the relative coherence of the clusters output
      by the algorithm.
  
  condensed_tree_ : CondensedTree object
      The condensed tree produced by HDBSCAN. The object has methods
      for converting to pandas, networkx, and plotting.
  
  single_linkage_tree_ : SingleLinkageTree object
      The single linkage tree produced by HDBSCAN. The object has methods
      for converting to pandas, networkx, and plotting.
  
  minimum_spanning_tree_ : MinimumSpanningTree object
      The minimum spanning tree of the mutual reachability graph generated
      by HDBSCAN. Note that this is not generated by default and will only
      be available if `gen_min_span_tree` was set to True on object creation.
      Even then in some optimized cases a tre may not be generated.
  
  outlier_scores_ : ndarray, shape (n_samples, )
      Outlier scores for clustered points; the larger the score the more
      outlier-like the point. Useful as an outlier detection technique.
      Based on the GLOSH algorithm by Campello, Moulavi, Zimek and Sander.
  
  prediction_data_ : PredictionData object
      Cached data used for predicting the cluster labels of new or
      unseen points. Necessary only if you are using functions from
      ``hdbscan.prediction`` (see
      :func:`~hdbscan.prediction.approximate_predict`,
      :func:`~hdbscan.prediction.membership_vector`,
      and :func:`~hdbscan.prediction.all_points_membership_vectors`).
  
  exemplars_ : list
      A list of exemplar points for clusters. Since HDBSCAN supports
      arbitrary shapes for clusters we cannot provide a single cluster
      exemplar per cluster. Instead a list is returned with each element
      of the list being a numpy array of exemplar points for a cluster --
      these points are the "most representative" points of the cluster.
  
  relative_validity_ : float
      A fast approximation of the Density Based Cluster Validity (DBCV)
      score [4]. The only differece, and the speed, comes from the fact
      that this relative_validity_ is computed using the mutual-
      reachability minimum spanning tree, i.e. minimum_spanning_tree_,
      instead of the all-points minimum spanning tree used in the
      reference. This score might not be an objective measure of the
      goodness of clusterering. It may only be used to compare results
      across different choices of hyper-parameters, therefore is only a
      relative score.
  
  References
  ----------
  
  .. [1] Campello, R. J., Moulavi, D., & Sander, J. (2013, April).
     Density-based clustering based on hierarchical density estimates.
     In Pacific-Asia Conference on Knowledge Discovery and Data Mining
     (pp. 160-172). Springer Berlin Heidelberg.
  
  .. [2] Campello, R. J., Moulavi, D., Zimek, A., & Sander, J. (2015).
     Hierarchical density estimates for data clustering, visualization,
     and outlier detection. ACM Transactions on Knowledge Discovery
     from Data (TKDD), 10(1), 5.
  
  .. [3] Chaudhuri, K., & Dasgupta, S. (2010). Rates of convergence for the
     cluster tree. In Advances in Neural Information Processing Systems
     (pp. 343-351).
  
  .. [4] Moulavi, D., Jaskowiak, P.A., Campello, R.J., Zimek, A. and
     Sander, J., 2014. Density-Based Clustering Validation. In SDM
     (pp. 839-847).
  
  .. [5] Malzer, C., & Baum, M. (2019). A Hybrid Approach To Hierarchical
         Density-based Cluster Selection. arxiv preprint 1911.02282.
class_docstr_tok: ["Perform","HDBSCAN","clustering","from","vector","array","or","distance","matrix",".","HDBSCAN","-","Hierarchical","Density-Based","Spatial","Clustering","of","Applications","with","Noise",".","Performs","DBSCAN","over","varying","epsilon","values","and","integrates","the","result","to","find","a","clustering","that","gives","the","best","stability","over","epsilon",".","This","allows","HDBSCAN","to","find","clusters","of","varying","densities","(","unlike","DBSCAN",")",",","and","be","more","robust","to","parameter","selection",".","Parameters","--","--","--","--","--","min_cluster_size",":","int",",","optional","(","default=5",")","The","minimum","size","of","clusters",";","single","linkage","splits","that","contain","fewer","points","than","this","will","be","considered","points","``","falling","out","''","of","a","cluster","rather","than","a","cluster","splitting","into","two","new","clusters",".","min_samples",":","int",",","optional","(","default=None",")","The","number","of","samples","in","a","neighbourhood","for","a","point","to","be","considered","a","core","point",".","metric",":","string",",","or","callable",",","optional","(","default='euclidean","'",")","The","metric","to","use","when","calculating","distance","between","instances","in","a","feature","array",".","If","metric","is","a","string","or","callable",",","it","must","be","one","of","the","options","allowed","by","metrics.pairwise.pairwise_distances","for","its","metric","parameter",".","If","metric","is","``","precomputed","''",",","X","is","assumed","to","be","a","distance","matrix","and","must","be","square",".","p",":","int",",","optional","(","default=None",")","p","value","to","use","if","using","the","minkowski","metric",".","alpha",":","float",",","optional","(","default=1.0",")","A","distance","scaling","parameter","as","used","in","robust","single","linkage",".","See","[","3","]","_","for","more","information",".","cluster_selection_epsilon",":","float",",","optional","(","default=0.0",")","A","distance","threshold",".","Clusters","below","this","value","will","be","merged",".","See","[","5","]","_","for","more","information",".","algorithm",":","string",",","optional","(","default='best","'",")","Exactly","which","algorithm","to","use",";","hdbscan","has","variants","specialised","for","different","characteristics","of","the","data",".","By","default","this","is","set","to","``","best","``","which","chooses","the","``","best","''","algorithm","given","the","nature","of","the","data",".","You","can","force","other","options","if","you","believe","you","know","better",".","Options","are",":","*","``","best","``","*","``","generic","``","*","``","prims_kdtree","``","*","``","prims_balltree","``","*","``","boruvka_kdtree","``","*","``","boruvka_balltree","``","leaf_size",":","int",",","optional","(","default=40",")","If","using","a","space","tree","algorithm","(","kdtree",",","or","balltree",")","the","number","of","points","ina","leaf","node","of","the","tree",".","This","does","not","alter","the","resulting","clustering",",","but","may","have","an","effect","on","the","runtime","of","the","algorithm",".","memory",":","Instance","of","joblib.Memory","or","string","(","optional",")","Used","to","cache","the","output","of","the","computation","of","the","tree",".","By","default",",","no","caching","is","done",".","If","a","string","is","given",",","it","is","the","path","to","the","caching","directory",".","approx_min_span_tree",":","bool",",","optional","(","default=True",")","Whether","to","accept","an","only","approximate","minimum","spanning","tree",".","For","some","algorithms","this","can","provide","a","significant","speedup",",","but","the","resulting","clustering","may","be","of","marginally","lower","quality",".","If","you","are","willing","to","sacrifice","speed","for","correctness","you","may","want","to","explore","this",";","in","general","this","should","be","left","at","the","default","True",".","gen_min_span_tree",":","bool",",","optional","(","default=False",")","Whether","to","generate","the","minimum","spanning","tree","with","regard","to","mutual","reachability","distance","for","later","analysis",".","core_dist_n_jobs",":","int",",","optional","(","default=4",")","Number","of","parallel","jobs","to","run","in","core","distance","computations","(","if","supported","by","the","specific","algorithm",")",".","For","``","core_dist_n_jobs","``","below","-1",",","(","n_cpus","+","1","+","core_dist_n_jobs",")","are","used",".","cluster_selection_method",":","string",",","optional","(","default='eom","'",")","The","method","used","to","select","clusters","from","the","condensed","tree",".","The","standard","approach","for","HDBSCAN","*","is","to","use","an","Excess","of","Mass","algorithm","to","find","the","most","persistent","clusters",".","Alternatively","you","can","instead","select","the","clusters","at","the","leaves","of","the","tree","--","this","provides","the","most","fine","grained","and","homogeneous","clusters",".","Options","are",":","*","``","eom","``","*","``","leaf","``","allow_single_cluster",":","bool",",","optional","(","default=False",")","By","default","HDBSCAN","*","will","not","produce","a","single","cluster",",","setting","this","to","True","will","override","this","and","allow","single","cluster","results","in","the","case","that","you","feel","this","is","a","valid","result","for","your","dataset",".","prediction_data",":","boolean",",","optional","Whether","to","generate","extra","cached","data","for","predicting","labels","or","membership","vectors","for","new","unseen","points","later",".","If","you","wish","to","persist","the","clustering","object","for","later","re-use","you","probably","want","to","set","this","to","True",".","(","default","False",")","match_reference_implementation",":","bool",",","optional","(","default=False",")","There","exist","some","interpretational","differences","between","this","HDBSCAN","*","implementation","and","the","original","authors","reference","implementation","in","Java",".","This","can","result","in","very","minor","differences","in","clustering","results",".","Setting","this","flag","to","True","will",",","at","a","some","performance","cost",",","ensure","that","the","clustering","results","match","the","reference","implementation",".","*","*","kwargs",":","optional","Arguments","passed","to","the","distance","metric","Attributes","--","--","--","--","--","labels_",":","ndarray",",","shape","(","n_samples",",",")","Cluster","labels","for","each","point","in","the","dataset","given","to","fit","(",")",".","Noisy","samples","are","given","the","label","-1.","probabilities_",":","ndarray",",","shape","(","n_samples",",",")","The","strength","with","which","each","sample","is","a","member","of","its","assigned","cluster",".","Noise","points","have","probability","zero",";","points","in","clusters","have","values","assigned","proportional","to","the","degree","that","they","persist","as","part","of","the","cluster",".","cluster_persistence_",":","ndarray",",","shape","(","n_clusters",",",")","A","score","of","how","persistent","each","cluster","is",".","A","score","of","1.0","represents","a","perfectly","stable","cluster","that","persists","over","all","distance","scales",",","while","a","score","of","0.0","represents","a","perfectly","ephemeral","cluster",".","These","scores","can","be","guage","the","relative","coherence","of","the","clusters","output","by","the","algorithm",".","condensed_tree_",":","CondensedTree","object","The","condensed","tree","produced","by","HDBSCAN",".","The","object","has","methods","for","converting","to","pandas",",","networkx",",","and","plotting",".","single_linkage_tree_",":","SingleLinkageTree","object","The","single","linkage","tree","produced","by","HDBSCAN",".","The","object","has","methods","for","converting","to","pandas",",","networkx",",","and","plotting",".","minimum_spanning_tree_",":","MinimumSpanningTree","object","The","minimum","spanning","tree","of","the","mutual","reachability","graph","generated","by","HDBSCAN",".","Note","that","this","is","not","generated","by","default","and","will","only","be","available","if","`","gen_min_span_tree","`","was","set","to","True","on","object","creation",".","Even","then","in","some","optimized","cases","a","tre","may","not","be","generated",".","outlier_scores_",":","ndarray",",","shape","(","n_samples",",",")","Outlier","scores","for","clustered","points",";","the","larger","the","score","the","more","outlier-like","the","point",".","Useful","as","an","outlier","detection","technique",".","Based","on","the","GLOSH","algorithm","by","Campello",",","Moulavi",",","Zimek","and","Sander",".","prediction_data_",":","PredictionData","object","Cached","data","used","for","predicting","the","cluster","labels","of","new","or","unseen","points",".","Necessary","only","if","you","are","using","functions","from","``","hdbscan.prediction","``","(","see",":","func",":","`","~hdbscan.prediction.approximate_predict","`",",",":","func",":","`","~hdbscan.prediction.membership_vector","`",",","and",":","func",":","`","~hdbscan.prediction.all_points_membership_vectors","`",")",".","exemplars_",":","list","A","list","of","exemplar","points","for","clusters",".","Since","HDBSCAN","supports","arbitrary","shapes","for","clusters","we","can","not","provide","a","single","cluster","exemplar","per","cluster",".","Instead","a","list","is","returned","with","each","element","of","the","list","being","a","numpy","array","of","exemplar","points","for","a","cluster","--","these","points","are","the","``","most","representative","''","points","of","the","cluster",".","relative_validity_",":","float","A","fast","approximation","of","the","Density","Based","Cluster","Validity","(","DBCV",")","score","[","4","]",".","The","only","differece",",","and","the","speed",",","comes","from","the","fact","that","this","relative_validity_","is","computed","using","the","mutual-","reachability","minimum","spanning","tree",",","i.e",".","minimum_spanning_tree_",",","instead","of","the","all-points","minimum","spanning","tree","used","in","the","reference",".","This","score","might","not","be","an","objective","measure","of","the","goodness","of","clusterering",".","It","may","only","be","used","to","compare","results","across","different","choices","of","hyper-parameters",",","therefore","is","only","a","relative","score",".","References","--","--","--","--","--","..","[","1","]","Campello",",","R.","J.",",","Moulavi",",","D.",",","&","Sander",",","J",".","(","2013",",","April",")",".","Density-based","clustering","based","on","hierarchical","density","estimates",".","In","Pacific-Asia","Conference","on","Knowledge","Discovery","and","Data","Mining","(","pp",".","160-172",")",".","Springer","Berlin","Heidelberg",".","..","[","2","]","Campello",",","R.","J.",",","Moulavi",",","D.",",","Zimek",",","A.",",","&","Sander",",","J",".","(","2015",")",".","Hierarchical","density","estimates","for","data","clustering",",","visualization",",","and","outlier","detection",".","ACM","Transactions","on","Knowledge","Discovery","from","Data","(","TKDD",")",",","10","(","1",")",",","5",".","..","[","3","]","Chaudhuri",",","K.",",","&","Dasgupta",",","S.","(","2010",")",".","Rates","of","convergence","for","the","cluster","tree",".","In","Advances","in","Neural","Information","Processing","Systems","(","pp",".","343-351",")",".","..","[","4","]","Moulavi",",","D.",",","Jaskowiak",",","P.A.",",","Campello",",","R.J.",",","Zimek",",","A.","and","Sander",",","J.",",","2014",".","Density-Based","Clustering","Validation",".","In","SDM","(","pp",".","839-847",")",".","..","[","5","]","Malzer",",","C.",",","&","Baum",",","M.","(","2019",")",".","A","Hybrid","Approach","To","Hierarchical","Density-based","Cluster","Selection",".","arxiv","preprint","1911.02282","."]
code: def minimum_spanning_tree_(self):
      if self._min_spanning_tree is not None:
          if self._raw_data is not None:
              return MinimumSpanningTree(
                  self._min_spanning_tree, self._raw_data
              )
          else:
              warn(
                  "No raw data is available; this may be due to using"
                  " a precomputed metric matrix. No minimum spanning"
                  " tree will be provided without raw data."
              )
              return None
      else:
          raise AttributeError(
              "No minimum spanning tree was generated."
              "This may be due to optimized algorithm variations that skip"
              " explicit generation of the spanning tree."
          )
  
imports: import numpy
  from sklearn.base import BaseEstimator, ClusterMixin
  from sklearn.metrics import pairwise_distances
  from scipy.sparse import issparse
  from sklearn.neighbors import KDTree, BallTree
  from joblib import Memory
  from warnings import warn
  from sklearn.utils import check_array
  from joblib.parallel import cpu_count
  from scipy.sparse import csgraph
  from ._hdbscan_linkage import single_linkage, mst_linkage_core, mst_linkage_core_vector, label
  from ._hdbscan_tree import condense_tree, compute_stability, get_clusters, outlier_scores
  from ._hdbscan_reachability import mutual_reachability, sparse_mutual_reachability
  from ._hdbscan_boruvka import KDTreeBoruvkaAlgorithm, BallTreeBoruvkaAlgorithm
  from .dist_metrics import DistanceMetric
  from .plots import CondensedTree, SingleLinkageTree, MinimumSpanningTree
  from .prediction import PredictionData
  from numpy import isclose
label_desc: Use image node_id 12 for calling the HDBSCAN obj's underlying member method code with example usage: obj.minimum_spanning_tree_() and returns: MinimumSpanningTree, None