Files

Ai4r::Clusterers::WeightedAverageLinkage

Implementation of an Agglomerative Hierarchical clusterer with weighted average linkage algorithm, aka weighted pair group method average or WPGMA (Jain and Dubes, 1988 ; McQuitty, 1966 ) Hierarchical clusteres create one cluster per element, and then progressively merge clusters, until the required number of clusters is reached. Similar to AverageLinkage, but the distances between clusters are weighted based on the number of data items in each of them.

D(cx, (ci U cj)) =  ( ni * D(cx, ci) + nj * D(cx, cj)) / (ni + nj)

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.

# File lib/ai4r/clusterers/weighted_average_linkage.rb, line 37
def build(data_set, number_of_clusters)
  super
end
eval(data_item) click to toggle source

This algorithms does not allow classification of new data items once it has been built. Rebuild the cluster including you data element.

# File lib/ai4r/clusterers/weighted_average_linkage.rb, line 43
def eval(data_item)
  Raise "Eval of new data is not supported by this algorithm."
end

Protected Instance Methods

linkage_distance(cx, ci, cj) click to toggle source

return distance between cluster cx and cluster (ci U cj), using weighted average linkage

# File lib/ai4r/clusterers/weighted_average_linkage.rb, line 51
def linkage_distance(cx, ci, cj)
  ni = @index_clusters[ci].length
  nj = @index_clusters[cj].length
  (1.0 * ni * read_distance_matrix(cx, ci)+
    nj * read_distance_matrix(cx, cj))/(ni+nj)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.