Module: Rumale::Base::ClusterAnalyzer
- Included in:
- Clustering::DBSCAN, Clustering::GaussianMixture, Clustering::KMeans, Clustering::KMedoids, Clustering::PowerIteration
- Defined in:
- lib/rumale/base/cluster_analyzer.rb
Overview
Module for all clustering algorithms in Rumale.
Instance Method Summary collapse
-
#fit_predict ⇒ Object
An abstract method for analyzing clusters and predicting cluster indices.
-
#score(x, y) ⇒ Float
Calculate purity of clustering result.
Instance Method Details
#fit_predict ⇒ Object
An abstract method for analyzing clusters and predicting cluster indices.
13 14 15 |
# File 'lib/rumale/base/cluster_analyzer.rb', line 13 def fit_predict raise NotImplementedError, "#{__method__} has to be implemented in #{self.class}." end |
#score(x, y) ⇒ Float
Calculate purity of clustering result.
22 23 24 25 26 27 28 |
# File 'lib/rumale/base/cluster_analyzer.rb', line 22 def score(x, y) check_sample_array(x) check_label_array(y) check_sample_label_size(x, y) evaluator = Rumale::EvaluationMeasure::Purity.new evaluator.score(y, fit_predict(x)) end |