Package moa.clusterers.clustree
Class Entry
- java.lang.Object
-
- moa.clusterers.clustree.Entry
-
- All Implemented Interfaces:
Serializable
public class Entry extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description ClusKernel
data
The actual entry data.
-
Constructor Summary
Constructors Modifier Constructor Description Entry(int numberDimensions)
Constructor for the entry.Entry(int numberDimensions, ClusKernel cluster, long currentTime)
Constructuctor that creates anEntry
with an empty buffer and thedata
given by theKernel
.protected
Entry(int numberDimensions, ClusKernel cluster, long currentTime, Entry parentEntry, Node containerNode)
extended constructor with containerNode and parentEntryprotected
Entry(int numberDimensions, Node node, long currentTime, Entry parentEntry, Node containerNode)
Constructor that creates anEntry
that points to the given node.protected
Entry(Entry other)
Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Entry other)
Add the data cluster of another entry to the data cluster of this entry.protected void
aggregateCluster(ClusKernel otherData, long currentTime, double negLambda)
Aggregate the givenKernel
to thedata
cluster of this entry.protected void
aggregateEntry(Entry other, long currentTime, double negLambda)
Aggregate thedata
in theKernel
of the otherEntry
.protected void
aggregateToBuffer(ClusKernel pointToInsert, long currentTime, double negLambda)
Aggregate the givenKernel
to thebuffer
cluster of this entry.protected double
calcDistance(ClusKernel cluster)
Calculates the distance to the data in this entry.double
calcDistance(Entry other)
Calculates the distance to the data in this entry of the data in the given entry.protected void
clear()
Clear the Entry.protected ClusKernel
emptyBuffer(long currentTime, double negLambda)
Clear the buffer in this entry and return a copy.protected ClusKernel
getBuffer()
Getter for the buffer.Node
getChild()
Return the reference to the child of thisEntry
to navigate in the tree.protected ClusKernel
getData()
Getter for the data.Node
getNode()
Entry
getParentEntry()
long
getTimestamp()
Return the current timestamp.protected void
initializeEntry(Entry other, long currentTime)
When this entry is empty, give it it's first values.protected boolean
isEmpty()
Check if thisEntry
is empty or not.protected boolean
isIrrelevant(double threshold)
Returns true if this entry is irrelevant with respecto the given threshold.protected void
makeOlder(long currentTime, double negLambda)
Ages this entrie's data AND buffer according to the given time and aging constant.protected void
mergeWith(Entry other)
Merge this entry witht the givenEntry
.protected void
overwriteOldEntry(Entry newEntry)
Overwrites the LS, SS and weightedN in the data cluster of thisEntry
to the values of the data cluster in the givenEntry
, but adds N and classCount of the cluster in the given Entry to the data cluster in this one.protected void
recalculateData()
This functions reads every entry in the child node and calculates the correspondingdata Kernel
.void
setChild(Node child)
Setter for the child in this entry.void
setNode(Node node)
void
setParentEntry(Entry parent)
protected void
shallowClear()
Clear thedata
and thebuffer Custer
in this entry.
-
-
-
Field Detail
-
data
public ClusKernel data
The actual entry data.
-
-
Constructor Detail
-
Entry
public Entry(int numberDimensions)
Constructor for the entry. To be used when we want to create an empty entry. Notice that the timestamp will be set to zero, since there is no reason to know when an empty entry was generated.- Parameters:
numberDimensions
- The dimensionality of the data point in tree where this entry is used.
-
Entry
protected Entry(int numberDimensions, Node node, long currentTime, Entry parentEntry, Node containerNode)
Constructor that creates anEntry
that points to the given node. The values ofdata
will be calculated for this.
-
Entry
public Entry(int numberDimensions, ClusKernel cluster, long currentTime)
Constructuctor that creates anEntry
with an empty buffer and thedata
given by theKernel
.- Parameters:
numberDimensions
- The dimensionality of the information in the cluster.cluster
- The cluster from which the information is to be extracted.currentTime
- The timestamp for the moment where this Entry was was generated.- See Also:
ClusKernel
,data
-
Entry
protected Entry(int numberDimensions, ClusKernel cluster, long currentTime, Entry parentEntry, Node containerNode)
extended constructor with containerNode and parentEntry- Parameters:
numberDimensions
-cluster
-currentTime
-parentEntry
-containerNode
-
-
Entry
protected Entry(Entry other)
Copy constructor. Everythin is copied, including the child.- Parameters:
other
-
-
-
Method Detail
-
getNode
public Node getNode()
-
setNode
public void setNode(Node node)
-
clear
protected void clear()
Clear the Entry. All points in the buffer and in the data cluster are lost, the connection to the child is lost and the timestamp is set to the default value.
-
shallowClear
protected void shallowClear()
Clear thedata
and thebuffer Custer
in this entry. This function does not clear the child of thisEntry
.- See Also:
data
,buffer
,ClusKernel
-
calcDistance
protected double calcDistance(ClusKernel cluster)
Calculates the distance to the data in this entry.- Parameters:
cluster
- The Kernel cluster to which the distance is to be calculated.- Returns:
- The distance to the data
Kernel
in thisEntry
- See Also:
ClusKernel
,data
-
calcDistance
public double calcDistance(Entry other)
Calculates the distance to the data in this entry of the data in the given entry.- Parameters:
other
- TheEntry
to which the distance is to be calculated.- Returns:
- The distance to the data
Kernel
in thisEntry
of the dataKernel
in the otherEntry
. - See Also:
ClusKernel
,data
-
initializeEntry
protected void initializeEntry(Entry other, long currentTime)
When this entry is empty, give it it's first values. It makes sense to have this operation separated from the aggregation, because the aggregation first weights the values indata
andKernel
, which makes no sense in an empty entry.- Parameters:
other
- The entry with the information to be used to initialize this entry.currentTime
- The time at which this is happening.
-
add
public void add(Entry other)
Add the data cluster of another entry to the data cluster of this entry. By using this function the timestamp does not get updated, nor does this entry get older.- Parameters:
other
- The entry of which the data cluster should be added to the local data cluster.- See Also:
data
,ClusKernel.add(ClusKernel)
-
aggregateEntry
protected void aggregateEntry(Entry other, long currentTime, double negLambda)
Aggregate thedata
in theKernel
of the otherEntry
.- Parameters:
other
- TheEntry
to be aggregated.- See Also:
data
,ClusKernel
-
aggregateCluster
protected void aggregateCluster(ClusKernel otherData, long currentTime, double negLambda)
Aggregate the givenKernel
to thedata
cluster of this entry.- Parameters:
otherData
- TheEntry
to be aggregated.- See Also:
data
,ClusKernel
-
aggregateToBuffer
protected void aggregateToBuffer(ClusKernel pointToInsert, long currentTime, double negLambda)
Aggregate the givenKernel
to thebuffer
cluster of this entry.- Parameters:
pointToInsert
- The cluster to aggregate to the buffer.currentTime
- The time at which the aggregation occurs.negLambda
- A parameter needed to weight the current state of the buffer.
-
mergeWith
protected void mergeWith(Entry other)
Merge this entry witht the givenEntry
. This adds the data cluster of the given Entry to the data cluster of this entry and sets the timestamp to the newest one of the the two entries.- Parameters:
other
- The entry from which the data cluster is added.- See Also:
ClusKernel.add(ClusKernel)
-
getBuffer
protected ClusKernel getBuffer()
Getter for the buffer. It is the real object, that means side effects are possible!- Returns:
- A reference to the buffer in this entry.
-
getChild
public Node getChild()
Return the reference to the child of thisEntry
to navigate in the tree.- Returns:
- A reference to the child of this
Entry
-
getData
protected ClusKernel getData()
Getter for the data. It is the real object, that means side effects are possible!- Returns:
- A reference to the data
Kernel
in this entry. - See Also:
ClusKernel
-
getParentEntry
public Entry getParentEntry()
-
setParentEntry
public void setParentEntry(Entry parent)
-
setChild
public void setChild(Node child)
Setter for the child in this entry. Use to build the tree.- Parameters:
child
- TheNode
that should be a child of thisEntry
- See Also:
Node
-
getTimestamp
public long getTimestamp()
Return the current timestamp.- Returns:
- The current timestamp.
-
emptyBuffer
protected ClusKernel emptyBuffer(long currentTime, double negLambda)
Clear the buffer in this entry and return a copy. No side effects are possible (given that the copy constructor ofKernel
makes a deep copy).- Returns:
- A copy of the buffer.
-
isEmpty
protected boolean isEmpty()
Check if thisEntry
is empty or not. AnEntry
is empty if thedata Kernel
is empty, since then the buffer has to be empty.- Returns:
true
if the data cluster has no data points,false
otherwise.
-
overwriteOldEntry
protected void overwriteOldEntry(Entry newEntry)
Overwrites the LS, SS and weightedN in the data cluster of thisEntry
to the values of the data cluster in the givenEntry
, but adds N and classCount of the cluster in the given Entry to the data cluster in this one. This function is useful when the weight of an entry becomes to small, and we want to forget the information of the old points.- Parameters:
newEntry
- The cluster that should overwrite the information.
-
recalculateData
protected void recalculateData()
This functions reads every entry in the child node and calculates the correspondingdata Kernel
. Timestamps are not changed.- See Also:
data
,ClusKernel
-
isIrrelevant
protected boolean isIrrelevant(double threshold)
Returns true if this entry is irrelevant with respecto the given threshold. This is done by comparing the weighted N of this Entry to the threshold, if it is smaller, than the entry is deemed to be irrelevant.- Parameters:
threshold
- The threshold under which entries at leafs can be erased.- Returns:
- True if this entry is deemed irrelevant, false otherwise.
-
makeOlder
protected void makeOlder(long currentTime, double negLambda)
Ages this entrie's data AND buffer according to the given time and aging constant.- Parameters:
currentTime
- the current timenegLambda
- the aging constant
-
-