class Ai4r::Clusterers::CompleteLinkage
Implementation of a Hierarchical clusterer with complete linkage (Everitt et al., 2001 ; Jain and Dubes, 1988 ; Sorensen, 1948 ). Hierarchical clusterer create one cluster per element, and then progressively merge clusters, until the required number of clusters is reached. With complete linkage, the distance between two clusters is computed as the maximum distance between elements of each cluster.
D(cx, (ci U cj) = max(D(cx, ci), D(cx, cj))
Public Instance Methods
build(data_set, number_of_clusters)
click to toggle source
Build a new clusterer, using data examples found in data_set. Items will be clustered in “number_of_clusters” different clusters.
Calls superclass method
# File lib/ai4r/clusterers/complete_linkage.rb, line 37 def build(data_set, number_of_clusters) super end
eval(data_item)
click to toggle source
Classifies the given data item, returning the cluster index it belongs to (0-based).
Calls superclass method
# File lib/ai4r/clusterers/complete_linkage.rb, line 43 def eval(data_item) super end
Protected Instance Methods
distance_between_item_and_cluster(data_item, cluster)
click to toggle source
# File lib/ai4r/clusterers/complete_linkage.rb, line 56 def distance_between_item_and_cluster(data_item, cluster) max_dist = 0 cluster.data_items.each do |another_item| dist = @distance_function.call(data_item, another_item) max_dist = dist if dist > max_dist end return max_dist end
linkage_distance(cx, ci, cj)
click to toggle source
return distance between cluster cx and new cluster (ci U cj), using complete linkage
# File lib/ai4r/clusterers/complete_linkage.rb, line 51 def linkage_distance(cx, ci, cj) [read_distance_matrix(cx, ci), read_distance_matrix(cx, cj)].max end