Class: Rumale::Clustering::DBSCAN
- Inherits:
-
Base::Estimator
- Object
- Base::Estimator
- Rumale::Clustering::DBSCAN
- Includes:
- Base::ClusterAnalyzer
- Defined in:
- rumale-clustering/lib/rumale/clustering/dbscan.rb
Overview
DBSCAN is a class that implements DBSCAN cluster analysis.
Reference
-
Ester, M., Kriegel, H-P., Sander, J., and Xu, X., “A density-based algorithm for discovering clusters in large spatial databases with noise,” Proc. KDD’ 96, pp. 266–231, 1996.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#core_sample_ids ⇒ Numo::Int32
readonly
Return the core sample indices.
-
#labels ⇒ Numo::Int32
readonly
Return the cluster labels.
Attributes inherited from Base::Estimator
Instance Method Summary collapse
-
#fit(x) ⇒ DBSCAN
Analysis clusters with given training data.
-
#fit_predict(x) ⇒ Numo::Int32
Analysis clusters and assign samples to clusters.
-
#initialize(eps: 0.5, min_samples: 5, metric: 'euclidean') ⇒ DBSCAN
constructor
Create a new cluster analyzer with DBSCAN method.
Methods included from Base::ClusterAnalyzer
Constructor Details
#initialize(eps: 0.5, min_samples: 5, metric: 'euclidean') ⇒ DBSCAN
Create a new cluster analyzer with DBSCAN method.
38 39 40 41 42 43 44 45 |
# File 'rumale-clustering/lib/rumale/clustering/dbscan.rb', line 38 def initialize(eps: 0.5, min_samples: 5, metric: 'euclidean') super() @params = { eps: eps, min_samples: min_samples, metric: (metric == 'precomputed' ? 'precomputed' : 'euclidean') } end |
Instance Attribute Details
#core_sample_ids ⇒ Numo::Int32 (readonly)
Return the core sample indices.
25 26 27 |
# File 'rumale-clustering/lib/rumale/clustering/dbscan.rb', line 25 def core_sample_ids @core_sample_ids end |
#labels ⇒ Numo::Int32 (readonly)
Return the cluster labels. The negative cluster label indicates that the point is noise.
29 30 31 |
# File 'rumale-clustering/lib/rumale/clustering/dbscan.rb', line 29 def labels @labels end |
Instance Method Details
#fit(x) ⇒ DBSCAN
Analysis clusters with given training data.
53 54 55 56 57 58 59 |
# File 'rumale-clustering/lib/rumale/clustering/dbscan.rb', line 53 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) partial_fit(x) self end |
#fit_predict(x) ⇒ Numo::Int32
Analysis clusters and assign samples to clusters.
66 67 68 69 70 71 72 |
# File 'rumale-clustering/lib/rumale/clustering/dbscan.rb', line 66 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) partial_fit(x) labels end |