Class: Ai4r::Clusterers::WardLinkageHierarchical
- Inherits:
-
WardLinkage
- Object
- Clusterer
- SingleLinkage
- WardLinkage
- Ai4r::Clusterers::WardLinkageHierarchical
- Defined in:
- lib/ai4r/clusterers/ward_linkage_hierarchical.rb
Overview
Hierarchical version to store classes as merges occur.
Instance Attribute Summary collapse
-
#cluster_tree ⇒ Object
readonly
Returns the value of attribute cluster_tree.
Attributes inherited from SingleLinkage
#clusters, #data_set, #number_of_clusters
Instance Method Summary collapse
- #build(data_set, number_of_clusters) ⇒ Object
-
#initialize(depth = nil) ⇒ WardLinkageHierarchical
constructor
A new instance of WardLinkageHierarchical.
Methods inherited from WardLinkage
Methods inherited from SingleLinkage
Methods inherited from Clusterer
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_tree ⇒ Object (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 |