Class: Ai4r::Clusterers::WardLinkage

Inherits:
SingleLinkage show all
Includes:
ClusterTree
Defined in:
lib/ai4r/clusterers/ward_linkage.rb

Overview

Implementation of an Agglomerative Hierarchical clusterer with Ward’s method linkage algorithm, aka the minimum variance method (Everitt et al., 2001 ; Jain and Dubes, 1988 ; Ward, 1963 ). Hierarchical clusterer create one cluster per element, and then progressively merge clusters, until the required number of clusters is reached. The objective of this method is to minimize the variance.

D(cx, (ci U cj)) =  (ni/(ni+nj+nx))*D(cx, ci) +
                    (nj/(ni+nj+nx))*D(cx, cj) -
                    (nx/(ni+nj)^2)*D(ci, cj)

Direct Known Subclasses

WardLinkageHierarchical

Instance Attribute Summary

Attributes included from ClusterTree

#cluster_tree

Attributes inherited from SingleLinkage

#clusters, #data_set, #number_of_clusters

Instance Method Summary collapse

Methods included from ClusterTree

#initialize

Methods inherited from SingleLinkage

#draw_map, #initialize, #silhouette

Methods included from Data::Parameterizable

#get_parameters, included, #set_parameters

Instance Method Details

#build(data_set, number_of_clusters = 1, **options) ⇒ Object

Build a new clusterer, using data examples found in data_set. Items will be clustered in “number_of_clusters” different clusters.

Parameters:

  • data_set (Object)
  • number_of_clusters (Object) (defaults to: 1)
  • *options (Object)

Returns:

  • (Object)


45
46
47
# File 'lib/ai4r/clusterers/ward_linkage.rb', line 45

def build(data_set, number_of_clusters = 1, **options)
  super
end

#eval(_data_item) ⇒ Object

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

Parameters:

  • _data_item (Object)

Returns:

  • (Object)

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/ai4r/clusterers/ward_linkage.rb', line 53

def eval(_data_item)
  raise NotImplementedError, 'Eval of new data is not supported by this algorithm.'
end

#supports_eval?Object

Returns:

  • (Object)


58
59
60
# File 'lib/ai4r/clusterers/ward_linkage.rb', line 58

def supports_eval?
  false
end