nuget server logo nuget api documents
↑

API Docs / Microsoft.VisualBasic.DataMining.HierarchicalClustering / CFTree

CFTree

Full name Microsoft.VisualBasic.DataMining.HierarchicalClustering.BIRCH.CFTree Assembly Microsoft.VisualBasic.DataMining.HierarchicalClustering Members 43

This is an implementation of the BIRCH clustering algorithm described in:

T. Zhang, R. Ramakrishnan, and M. Livny. "BIRCH: A New Data Clustering Algorithm and Its Applications" Data Mining and Knowledge Discovery, 1997.

@author Roberto Perdisci (roberto.perdisci@gmail.com) @version 0.1

00 Remarks

https://github.com/sehee-lee/JBIRCH

01 Syntax

Microsoft.VisualBasic.DataMining.HierarchicalClustering.BIRCH.CFTree

02 Methods

NameOverloadsSummary
.ctor 1
MemoryLimitMB 1
AutomaticRebuild 1
PeriodicMemLimitCheck 1
insertEntry 3 Inserts an entire CFEntry into the tree.
rebuildIfAboveMemLimit 1 Every time we split the root, we check whether the memory limit imposed on the tree has been reached.
splitRoot 1 Splits the root to accommodate a new entry.
copyTree 1 Overwrites the structure of this tree (all nodes, entreis, and leaf list) with the structure of newTree.
computeNewThreshold 1 Computes a new threshold based on the average distance of the closest subclusters in each leaf node
hasReachedMemoryLimit 1 True if CFTree's memory occupation exceeds or is almost equal to the memory limit
computeMemorySize 1 Computes the memory usage of a CFTree
rebuildTree 1 This implementation of the rebuilding algorithm is different from the one described in Section 4.5 of the paper.
finishedInsertingData 1 Signals the fact that we finished inserting data.
mapToClosestSubcluster 1 Retrieves the subcluster id of the closest leaf entry to e
computeSumLambdaSquared 1 Computes an estimate of the cost of running an O(n^2) algorithm to split each subcluster in more fine-grained clusters
printCFTree 1 prints the CFTree
countNodes 1 Counts the nodes of the tree (including leaves)
countEntries 1 Counts the number of CFEntries in the tree
countLeafEntries 1 Counts the number of leaf entries (i.e., the number of sub-clusters in the tree)
printLeafIndexes 1 Prints the index of all the pattern vectors that fall into the leaf nodes.
printLeafEntries 1 Prints the index of the pattern vectors in each leaf entry (i.e., each subcluster)

03 Properties

NameOverloadsSummary
MemoryLimit 1
LeafListStart 1 Gets the start of the list of leaf nodes (remember: the first node is a dummy node) @return
SubclusterMembers 1

04 Fields

NameOverloadsSummary
MEM_LIM_FRAC 1 Used when computing if the tree is reaching memory limit
D0_DIST 2 Centroid Distance D0
D1_DIST 2 Centroid distance D1
D2_DIST 2 Cluster Distance D2
D3_DIST 2 Cluster Distance D3
D4_DIST 2 Cluster Distance D4
root 1 The root node of the CFTree
leafListStartField 1 dummy node that points to the list of leaves.
instanceIndex 1 keeps count of the instances inserted into the tree
automaticRebuildField 1 if true, the tree is automatically rebuilt every time the memory limit is reached
memLimit 1 the memory limit used when automatic rebuilding is active
periodicMemLimitCheckField 1 used when automatic rebuilding is active

05 Members

method .ctor #
#ctor(Int32, Double, Int32, Boolean)
Parameters
NameTypeDescription
maxNodeEntriesInt32

parameter B

distThresholdDouble

parameter T

distFunctionInt32

must be one of CFTree.D0_DIST,...,CFTree.D4_DIST, otherwise it will default to D0_DIST

applyMergingRefinementBoolean

if true, activates merging refinement after each node split

method MemoryLimitMB #
MemoryLimitMB(Int64)
Parameters
NameTypeDescription
limitInt64

memory limit in Mbytes

method AutomaticRebuild #
AutomaticRebuild(Boolean)
Parameters
NameTypeDescription
autoBoolean

if true, and memory limit is reached, the tree is automatically rebuilt with larger threshold

method PeriodicMemLimitCheck #
PeriodicMemLimitCheck(Int64)
Parameters
NameTypeDescription
periodInt64

the number of insert operations after which we check whether the tree has reached the memory limit

method insertEntry overload 3 #
insertEntry(Double())

Inserts a single pattern vector into the CFTree

Parameters
NameTypeDescription
xDouble()

the pattern vector to be inserted in the tree

Returns

true if insertion was successful

method insertEntry overload 2 #
insertEntry(Double(), Int32)

Insert a pattern vector with a specific associated pattern vector index. This method does not use periodic memory limit checks.

Parameters
NameTypeDescription
xDouble()

the pattern vector to be inserted in the tree

indexInt32

a specific index associated to the pattern vector x

Returns

true if insertion was successful

method insertEntry #
insertEntry(CFEntry)

Inserts an entire CFEntry into the tree. Used for tree rebuilding.

Parameters
NameTypeDescription
eCFEntry

the CFEntry to insert

Returns

true if insertion happened without problems

method rebuildIfAboveMemLimit #
rebuildIfAboveMemLimit

Every time we split the root, we check whether the memory limit imposed on the tree has been reached. In this case, we automatically increase the distance threshold and rebuild the tree.

It is worth noting that since we only check memory consumption only during root split, and not for all node splits (for performance reasons), we cannot guarantee that the memory limit will not be exceeded. The tree may grow significantly between a root split and the next. Furthermore, the computation of memory consumption using the SizeOf class is only approximate.

Notice also that if the threshold grows to the point that all the entries fall into one entry of the root (i.e., the root is the only node in the tree, and has only one sub-cluster) the automatic rebuild cannot decrease the memory consumption (because increasing the threshold has not effect on reducing the size of the tree), and if Java runs out of memory the program will terminate.

Returns

true if rebuilt

method splitRoot #
splitRoot

Splits the root to accommodate a new entry. The height of the tree grows by one.

method copyTree #
copyTree(CFTree)

Overwrites the structure of this tree (all nodes, entreis, and leaf list) with the structure of newTree.

Parameters
NameTypeDescription
newTreeCFTree

the tree to be copied

method computeNewThreshold #
computeNewThreshold(CFNode, Int32, Double)

Computes a new threshold based on the average distance of the closest subclusters in each leaf node

Parameters
NameTypeDescription
leafListStartCFNode

the pointer to the start of the list (the first node is assumed to be a place-holder dummy node)

distFunctionInt32

-

currentThresholdDouble

-

Returns

the new threshold

method hasReachedMemoryLimit #
hasReachedMemoryLimit(CFTree, Int64)

True if CFTree's memory occupation exceeds or is almost equal to the memory limit

Parameters
NameTypeDescription
treeCFTree

the tree to be tested

limitInt64

the memory limit

Returns

true if memory limit has been reached

method computeMemorySize #
computeMemorySize(CFTree)

Computes the memory usage of a CFTree

Parameters
NameTypeDescription
tCFTree

a CFTree

Returns

memory usage in bytes

method rebuildTree #
rebuildTree(Int32, Double, Int32, Boolean, Boolean)

This implementation of the rebuilding algorithm is different from the one described in Section 4.5 of the paper. However the effect is practically the same. Namely, given a tree t_i build using threshold T_i, if we set a new threshold T_(i+1) and call rebuildTree (assuming maxEntries stays the same) we will obtain a more compact tree.

Since the CFTree is sensitive to the order of the data, there may be cases in which, if we set the T(i+1) so that non of the sub-clusters (i.e., the leaf entries) can be merged (e.g., T(i+1)=-1) we might actually obtain a new tree t_(i+1) containing more nodes than t_i. However, the obtained sub-clusters in t_(i+1) will be identical to the sub-clusters in t_i.

In practice, though, if T(i+1) > T(i), the tree t_(i+1) will usually be smaller than t_i. Although the Reducibility Theorem in Section 4.5 may not hold anymore, in practice this will not be a big problem, since even in those cases in which t_(i+1)>t_i, the growth should be very small.

The advantage is that relaxing the constraint that the size of t_(i+1) must be less than t_i makes the implementation of the rebuilding algorithm much easier.

Parameters
NameTypeDescription
newMaxEntriesInt32

the new number of entries per node

newThresholdDouble

the new threshold

applyMergingRefinementInt32

if true, merging refinement will be applied after every split

discardOldTreeBoolean

if true, the old tree will be discarded (to free memory)

Returns

the new (usually more compact) CFTree

method finishedInsertingData #
finishedInsertingData

Signals the fact that we finished inserting data. The obtained subclusters will be assigned a positive, unique ID number

method mapToClosestSubcluster #
mapToClosestSubcluster(Double())

Retrieves the subcluster id of the closest leaf entry to e

Parameters
NameTypeDescription
xDouble()

the entry to be mapped

Returns

a positive integer, if the leaf entries were enumerated using finishedInsertingData(), otherwise -1

method computeSumLambdaSquared #
computeSumLambdaSquared

Computes an estimate of the cost of running an O(n^2) algorithm to split each subcluster in more fine-grained clusters

Returns

sqrt(sum_i[(n_i)^2]), where n_i is the number of members of the i-th subcluster

method printCFTree #
printCFTree

prints the CFTree

method countNodes #
countNodes

Counts the nodes of the tree (including leaves)

Returns

the number of nodes in the tree

method countEntries #
countEntries

Counts the number of CFEntries in the tree

Returns

the number of entries in the tree

method countLeafEntries #
countLeafEntries

Counts the number of leaf entries (i.e., the number of sub-clusters in the tree)

Returns

the number of leaf entries (i.e., the number of sub-clusters)

method printLeafIndexes #
printLeafIndexes

Prints the index of all the pattern vectors that fall into the leaf nodes. This is only useful for debugging purposes.

method printLeafEntries #
printLeafEntries

Prints the index of the pattern vectors in each leaf entry (i.e., each subcluster)

property MemoryLimit #
MemoryLimit
Returns

the current memory limit used to trigger automatic rebuilding

property LeafListStart #
LeafListStart

Gets the start of the list of leaf nodes (remember: the first node is a dummy node)

@return

property SubclusterMembers #
SubclusterMembers
Returns

a list of subcluster, and for each subcluster a list of pattern vector indexes that belong to it

field MEM_LIM_FRAC #
MEM_LIM_FRAC

Used when computing if the tree is reaching memory limit

field D0_DIST #
D0_DIST

Centroid Distance D0

field D1_DIST #
D1_DIST

Centroid distance D1

field D2_DIST #
D2_DIST

Cluster Distance D2

field D3_DIST #
D3_DIST

Cluster Distance D3

field D4_DIST #
D4_DIST

Cluster Distance D4

field root #
root

The root node of the CFTree

field leafListStartField #
leafListStartField

dummy node that points to the list of leaves. used for fast retrieval of final subclusters

field instanceIndex #
instanceIndex

keeps count of the instances inserted into the tree

field automaticRebuildField #
automaticRebuildField

if true, the tree is automatically rebuilt every time the memory limit is reached

field memLimit #
memLimit

the memory limit used when automatic rebuilding is active

field periodicMemLimitCheckField #
periodicMemLimitCheckField

used when automatic rebuilding is active

field D0_DIST overload 2 #
D0_DIST
field D1_DIST overload 2 #
D1_DIST
field D2_DIST overload 2 #
D2_DIST
field D3_DIST overload 2 #
D3_DIST
field D4_DIST overload 2 #
D4_DIST