test/clusterers/complete_linkage_test.rb in ai4r-1.5 vs test/clusterers/complete_linkage_test.rb in ai4r-1.6
- old
+ new
@@ -1,11 +1,20 @@
+# Author:: Sergio Fierens (implementation)
+# License:: MPL 1.1
+# Project:: ai4r
+# Url:: http://ai4r.rubyforge.org/
+#
+# You can redistribute it and/or modify it under the terms of
+# the Mozilla Public License version 1.1 as published by the
+# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
+
require 'test/unit'
require File.dirname(__FILE__) + '/../../lib/ai4r/clusterers/complete_linkage'
class Ai4r::Clusterers::CompleteLinkage
attr_accessor :data_set, :number_of_clusters, :clusters, :distance_matrix
- public :calc_index_clusters_distance
+ public :linkage_distance
public :distance_between_item_and_cluster
end
class CompleteLinkageTest < Test::Unit::TestCase
@@ -26,14 +35,14 @@
[100.0, 2.0, 1.0, 16.0, 2.0, 100.0, 37.0, 100.0],
[68.0, 26.0, 9.0, 0.0, 10.0, 68.0, 5.0, 52.0, 16.0],
[49.0, 49.0, 26.0, 5.0, 25.0, 49.0, 4.0, 29.0, 37.0, 5.0],
[2.0, 72.0, 65.0, 50.0, 52.0, 2.0, 65.0, 10.0, 74.0, 50.0, 37.0]]
- def test_calc_index_clusters_distance
- clusterer = CompleteLinkage.new
+ def test_linkage_distance
+ clusterer = Ai4r::Clusterers::CompleteLinkage.new
clusterer.distance_matrix = @@expected_distance_matrix
- assert_equal 98.0, clusterer.calc_index_clusters_distance([0], [1])
- assert_equal 74.0, clusterer.calc_index_clusters_distance([0, 1], [3, 4])
+ assert_equal 98, clusterer.linkage_distance(0,1,2)
+ assert_equal 74, clusterer.linkage_distance(4,2,5)
end
def test_distance_between_item_and_cluster
clusterer = CompleteLinkage.new
assert_equal 32.0, clusterer.distance_between_item_and_cluster([1,2],