class Ai4r::Clusterers::Clusterer
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.
Public Instance Methods
build(data_set, number_of_clusters)
click to toggle source
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
eval(data_item)
click to toggle source
Classifies the given data item, returning the cluster it belongs to.
# File lib/ai4r/clusterers/clusterer.rb, line 30 def eval(data_item) raise NotImplementedError end
Protected Instance Methods
get_min_index(array)
click to toggle source
# File lib/ai4r/clusterers/clusterer.rb, line 35 def get_min_index(array) min = array.first index = 0 array.each_index do |i| x = array[i] if x < min min = x index = i end end return index end