Package moa.clusterers.clustree
Class Node
- java.lang.Object
-
- moa.clusterers.clustree.Node
-
- All Implemented Interfaces:
Serializable
public class Node extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description Node(int numberDimensions, int level)
Initialze a normal node, which is not fake.protected
Node(int numberDimensions, int numberClasses, int level, boolean fakeRoot)
Initialiazes a node which is a fake root depending on the givenboolean
.Node(int numberDimensions, int level, Entry[] argEntries)
USED FOR EM_TOP_DOWN BULK LOADING
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEntry(Entry newEntry, long currentTime)
Add a newEntry
to this node.protected void
clear()
Clear this Node, which means that the noiseBuffer is cleared, thatshallowClear
is called upon all the entries of the node, that the split counter is set to zero and the node is set to not be a fake root.Entry[]
getEntries()
Return an array with references to the children of this node.protected Entry
getIrrelevantEntry(double threshold)
If there exists an entry, whose relevance is under the threshold given as a parameter to the tree, this entry is returned.protected int
getLevel(ClusTree tree)
Returns the level at which this node is in the tree.protected int
getRawLevel()
Return the level number in the node.protected boolean
isLeaf()
Checks if this node is a leaf.protected void
makeOlder(long currentTime, double negLambda)
protected void
mergeEntries(int pos1, int pos2)
Merge the two entries at the given position.Entry
nearestEntry(ClusKernel buffer)
Returns the neareastEntry
to the givenCluster
.protected Entry
nearestEntry(Entry newEntry)
Return the nearest entry to the given one.protected int
numFreeEntries()
Return the number of freeEntry
s in this node.
-
-
-
Constructor Detail
-
Node
public Node(int numberDimensions, int level)
Initialze a normal node, which is not fake.- Parameters:
numberDimensions
- The dimensionality of the data points it manipulates.level
- The INVERSE level at which this node hangs.
-
Node
protected Node(int numberDimensions, int numberClasses, int level, boolean fakeRoot)
Initialiazes a node which is a fake root depending on the givenboolean
.- Parameters:
numberDimensions
- The dimensionality of the data points it manipulates.level
- The level at which this node hangs.fakeRoot
- A parameter the says if the node is to be fake or not.
-
Node
public Node(int numberDimensions, int level, Entry[] argEntries)
USED FOR EM_TOP_DOWN BULK LOADING- Parameters:
numberDimensions
-level
-argEntries
-
-
-
Method Detail
-
isLeaf
protected boolean isLeaf()
Checks if this node is a leaf. A node is a leaf when none of the entries in the node have children.- Returns:
true
if the node is leaf,false
otherwise.
-
nearestEntry
public Entry nearestEntry(ClusKernel buffer)
Returns the neareastEntry
to the givenCluster
. The distance is minimized overEntry.calcDistance(Cluster)
.- Parameters:
buffer
- The cluster to which the distance has to be compared.- Returns:
- The
Entry
with minimal distance to the given cluster. - See Also:
ClusKernel
,Entry.calcDistance(ClusKernel)
-
nearestEntry
protected Entry nearestEntry(Entry newEntry)
Return the nearest entry to the given one. ThecalcDistance(Entry)
function is find the one with the shortest distance in this node to the given one.- Parameters:
newEntry
- The entry to which the entry with the minimal distance to it is calculated.- Returns:
- The entry with the minimal distance to the given one.
-
numFreeEntries
protected int numFreeEntries()
Return the number of freeEntry
s in this node.- Returns:
- The number of free
Entry
s in this node. - See Also:
Entry
-
addEntry
public void addEntry(Entry newEntry, long currentTime)
Add a newEntry
to this node. If there is no space left aNoFreeEntryException
is thrown.- Parameters:
newEntry
- TheEntry
to be added.- Throws:
RuntimeException
- Is thrown when there is no space left in the node for the new entry.
-
getIrrelevantEntry
protected Entry getIrrelevantEntry(double threshold)
If there exists an entry, whose relevance is under the threshold given as a parameter to the tree, this entry is returned. Otherwisenull
is returned.- Returns:
- An irrelevant
Entry
if there exists one,null
otherwise. - See Also:
Entry
,Entry.isIrrelevant(double)
-
getEntries
public Entry[] getEntries()
Return an array with references to the children of this node. These are not copies, that means side effects are possible!- Returns:
- An array with references to the children of this node.
- See Also:
Entry
-
getRawLevel
protected int getRawLevel()
Return the level number in the node. This is not the real level. For the real level one has to callgetLevel(Tree tree)
.- Returns:
- The raw level of the node.
- See Also:
getLevel(ClusTree)
-
getLevel
protected int getLevel(ClusTree tree)
Returns the level at which this node is in the tree. If a tree is passed to which the node does not belonged a value is returned, but it is gibberish.- Parameters:
tree
- The tree to which this node belongs.- Returns:
- The level at which this node hangs.
-
clear
protected void clear()
Clear this Node, which means that the noiseBuffer is cleared, thatshallowClear
is called upon all the entries of the node, that the split counter is set to zero and the node is set to not be a fake root. Notice that the level stays the same after calling this function.- See Also:
ClusKernel.clear()
,Entry.shallowClear()
-
mergeEntries
protected void mergeEntries(int pos1, int pos2)
Merge the two entries at the given position. The entries are reordered in theentries
array so that the non-empty entries are still at the beginning.- Parameters:
pos1
- The position of the first entry to be merged. This position has to be smaller than the the second position.pos2
- The position of the second entry to be merged. This position has to be greater than the the first position.
-
makeOlder
protected void makeOlder(long currentTime, double negLambda)
-
-