ca.pfv.spmf.patterns.cluster
Class Cluster
- java.lang.Object
-
- ca.pfv.spmf.patterns.cluster.Cluster
-
public class Cluster extends java.lang.ObjectThis class represents a cluster found by a clustering algorithm such as K-Means. A cluster is a list of vectors of doubles.- See Also:
DoubleArray
-
-
Constructor Summary
Constructors Constructor and Description Cluster(int vectorsSize)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddVector(DoubleArray vector)Add a vector of doubles to this cluster.booleancontains(DoubleArray vector)Check if a vector is contained in this cluster.DoubleArraygetmean()Getter for the meanjava.util.List<DoubleArray>getVectors()Method to get the vectors in this clustervoidrecomputeClusterMean()This method is called by clustering algorithms to recompute the mean of the cluster.voidremove(DoubleArray vector)Method to remove a vector from this cluster and update the internal sum of vectors at the same time.voidremoveVector(DoubleArray vector)Method to remove a vector from this cluster without updating internal structures.voidsetMean(DoubleArray mean)Setter for the mean of this cluster.java.lang.StringtoString()Return a string representing this cluster.
-
-
-
Constructor Detail
-
Cluster
public Cluster(int vectorsSize)
Constructor- Parameters:
vectorsSize- the size of the vectors to be stored in this cluster
-
-
Method Detail
-
setMean
public void setMean(DoubleArray mean)
Setter for the mean of this cluster.- Parameters:
mean- A vector of double that will be set as the mean of this cluster.
-
addVector
public void addVector(DoubleArray vector)
Add a vector of doubles to this cluster.- Parameters:
vector- The vector of doubles to be added.
-
getmean
public DoubleArray getmean()
Getter for the mean- Returns:
- return the mean of this cluster
-
toString
public java.lang.String toString()
Return a string representing this cluster.- Overrides:
toStringin classjava.lang.Object
-
recomputeClusterMean
public void recomputeClusterMean()
This method is called by clustering algorithms to recompute the mean of the cluster.
-
getVectors
public java.util.List<DoubleArray> getVectors()
Method to get the vectors in this cluster- Returns:
- the vectors.
-
remove
public void remove(DoubleArray vector)
Method to remove a vector from this cluster and update the internal sum of vectors at the same time.- Parameters:
vector- the vector to be removed
-
removeVector
public void removeVector(DoubleArray vector)
Method to remove a vector from this cluster without updating internal structures.- Parameters:
vector- the vector to be removed
-
contains
public boolean contains(DoubleArray vector)
Check if a vector is contained in this cluster.- Parameters:
vector- A vector of doubles- Returns:
- true if the vector is contained in this cluster.
-
-
DMelt 3.0 © DataMelt by jWork.ORG