medusa.spectral
Class KMeans
- java.lang.Object
-
- medusa.spectral.KMeans
-
public class KMeans extends java.lang.ObjectImplements the k-means algorithm
-
-
Constructor Summary
Constructors Constructor and Description KMeans(int k, java.util.List<KMeansPoint> kMeansPoints)Returns a new instance of kMeans algorithmKMeans(int k, java.lang.String inputFileName)Returns a new instance of kMeans algorithm
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description medusa.spectral.clustergetCluster(int index)Returns the specified cluster by indexjava.util.Map<java.lang.String,java.lang.Integer>getClusterMap()java.util.Vector<KMeansPoint>[]getClusters()java.util.VectorgetDataPoints()Returns the data pointsintgetK()Returns the value of kintgetSmallestClusterSize()java.util.Vector<KMeansPoint>getVector()static voidmain(java.lang.String[] args)Main method -- to test the kMeans classvoidreadData()Reads the input data from the file and stores the data points in the vectorvoidrunKMeans()Runs the k-means algorithm over the data setjava.lang.StringtoString()Returns the string output of the data points
-
-
-
Constructor Detail
-
KMeans
public KMeans(int k, java.lang.String inputFileName)Returns a new instance of kMeans algorithm- Parameters:
k- number of clustersinputFileName- name of the file containing input data
-
KMeans
public KMeans(int k, java.util.List<KMeansPoint> kMeansPoints)Returns a new instance of kMeans algorithm- Parameters:
k- number of clusterskMeansPoints- List containing objects of type kMeansPoint
-
-
Method Detail
-
readData
public void readData() throws java.io.IOExceptionReads the input data from the file and stores the data points in the vector- Throws:
java.io.IOException
-
getVector
public java.util.Vector<KMeansPoint> getVector()
-
runKMeans
public void runKMeans()
Runs the k-means algorithm over the data set
-
getClusters
public java.util.Vector<KMeansPoint>[] getClusters()
-
getK
public int getK()
Returns the value of k- Returns:
- the value of k
-
getCluster
public medusa.spectral.cluster getCluster(int index)
Returns the specified cluster by index- Parameters:
index- index of the cluster to be returned- Returns:
- return the specified cluster by index
-
toString
public java.lang.String toString()
Returns the string output of the data points- Overrides:
toStringin classjava.lang.Object- Returns:
- the string output of the data points
-
getDataPoints
public java.util.Vector getDataPoints()
Returns the data points- Returns:
- the data points
-
getClusterMap
public java.util.Map<java.lang.String,java.lang.Integer> getClusterMap()
-
getSmallestClusterSize
public int getSmallestClusterSize()
-
main
public static void main(java.lang.String[] args)
Main method -- to test the kMeans class- Parameters:
args- command line arguments
-
-
DMelt 3.0 © DataMelt by jWork.ORG