Class: FeldtRuby::AverageLinkageMetric

Inherits:
ClusterLinkageMetric show all
Defined in:
lib/feldtruby/statistics/clustering.rb

Overview

Average linkage metric between clusters.

Instance Method Summary collapse

Methods included from SetDistance

#pairwise_distances

Methods included from CompositableDistance

#initialize

Instance Method Details

#calc(cluster1, cluster2) ⇒ Object



12
13
14
# File 'lib/feldtruby/statistics/clustering.rb', line 12

def calc(cluster1, cluster2)
  pairwise_distances(cluster1, cluster2, @sub_metric).sum.to_f / (cluster1.length * cluster2.length)
end