Class: Ai4r::Clusterers::WardLinkageHierarchical

Inherits:
WardLinkage show all
Defined in:
lib/ai4r/clusterers/ward_linkage_hierarchical.rb

Overview

Hierarchical version to store classes as merges occur.

Instance Attribute Summary collapse

Attributes inherited from SingleLinkage

#clusters, #data_set, #number_of_clusters

Instance Method Summary collapse

Methods inherited from WardLinkage

#eval

Methods inherited from SingleLinkage

#eval

Methods inherited from Clusterer

#eval

Methods included from Data::Parameterizable

#get_parameters, included, #set_parameters

Constructor Details

#initialize(depth = nil) ⇒ WardLinkageHierarchical

Returns a new instance of WardLinkageHierarchical.



16
17
18
19
20
21
# File 'lib/ai4r/clusterers/ward_linkage_hierarchical.rb', line 16

def initialize(depth = nil)
  @cluster_tree = []
  @depth = depth
  @merges_so_far = 0
  super()
end

Instance Attribute Details

#cluster_treeObject (readonly)

Returns the value of attribute cluster_tree.



14
15
16
# File 'lib/ai4r/clusterers/ward_linkage_hierarchical.rb', line 14

def cluster_tree
  @cluster_tree
end

Instance Method Details

#build(data_set, number_of_clusters) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/ai4r/clusterers/ward_linkage_hierarchical.rb', line 23

def build(data_set, number_of_clusters)
  data_len = data_set.data_items.length
  @total_merges = data_len - number_of_clusters
  super
  @cluster_tree << self.clusters
  @cluster_tree.reverse!
  return self
end