Class: Rumale::Clustering::HDBSCAN
- Inherits:
-
Base::Estimator
- Object
- Base::Estimator
- Rumale::Clustering::HDBSCAN
- Includes:
- Base::ClusterAnalyzer
- Defined in:
- rumale-clustering/lib/rumale/clustering/hdbscan.rb
Overview
HDBSCAN is a class that implements HDBSCAN cluster analysis.
Reference
-
Campello, R J. G. B., Moulavi, D., Zimek, A., and Sander, J., “Hierarchical Density Estimates for Data Clustering, Visualization, and Outlier Detection,” TKDD, Vol. 10 (1), pp. 5:1–5:51, 2015.
-
Campello, R J. G. B., Moulavi, D., and Sander, J., “Density-Based Clustering Based on Hierarchical Density Estimates,” Proc. PAKDD’13, pp. 160–172, 2013.
-
Lelis, L., and Sander, J., “Semi-Supervised Density-Based Clustering,” Proc. ICDM’09, pp. 842–847, 2009.
Instance Attribute Summary collapse
-
#labels ⇒ Numo::Int32
readonly
Return the cluster labels.
Attributes inherited from Base::Estimator
Instance Method Summary collapse
-
#fit(x) ⇒ HDBSCAN
Analysis clusters with given training data.
-
#fit_predict(x) ⇒ Numo::Int32
Analysis clusters and assign samples to clusters.
-
#initialize(min_samples: 10, min_cluster_size: nil, metric: 'euclidean') ⇒ HDBSCAN
constructor
Create a new cluster analyzer with HDBSCAN algorithm.
Methods included from Base::ClusterAnalyzer
Constructor Details
#initialize(min_samples: 10, min_cluster_size: nil, metric: 'euclidean') ⇒ HDBSCAN
Create a new cluster analyzer with HDBSCAN algorithm.
37 38 39 40 41 42 43 44 |
# File 'rumale-clustering/lib/rumale/clustering/hdbscan.rb', line 37 def initialize(min_samples: 10, min_cluster_size: nil, metric: 'euclidean') super() @params = { min_samples: min_samples, min_cluster_size: min_cluster_size || min_samples, metric: (metric == 'precomputed' ? 'precomputed' : 'euclidean') } end |
Instance Attribute Details
#labels ⇒ Numo::Int32 (readonly)
Return the cluster labels. The negative cluster label indicates that the point is noise.
28 29 30 |
# File 'rumale-clustering/lib/rumale/clustering/hdbscan.rb', line 28 def labels @labels end |
Instance Method Details
#fit(x) ⇒ HDBSCAN
Analysis clusters with given training data.
52 53 54 55 56 57 58 |
# File 'rumale-clustering/lib/rumale/clustering/hdbscan.rb', line 52 def fit(x, _y = nil) x = ::Rumale::Validation.check_convert_sample_array(x) raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape(x) fit_predict(x) self end |
#fit_predict(x) ⇒ Numo::Int32
Analysis clusters and assign samples to clusters.
65 66 67 68 69 70 71 |
# File 'rumale-clustering/lib/rumale/clustering/hdbscan.rb', line 65 def fit_predict(x) x = ::Rumale::Validation.check_convert_sample_array(x) raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape(x) distance_mat = @params[:metric] == 'precomputed' ? x : ::Rumale::PairwiseMetric.euclidean_distance(x) @labels = partial_fit(distance_mat) end |