Object
The purpose of this class is to define a common API for Clusterers. All methods in this class (other than eval) must be implemented in subclasses.
Build a new clusterer, using data examples found in data_set. Data items will be clustered in “number_of_clusters” different clusters.
# File lib/ai4r/clusterers/clusterer.rb, line 25 def build(data_set, number_of_clusters) raise NotImplementedError end
Usefull as a defult distance function for clustering algorithms
# File lib/ai4r/clusterers/clusterer.rb, line 36 def euclidean_distance(a, b) dist = 0.0 a.each_index do |index| if a[index].is_a?(Numeric) && b[index].is_a?(Numeric) dist = dist + ((a[index]-b[index])*(a[index]-b[index])) end end return dist end
Generated with the Darkfish Rdoc Generator 2.