medusa.georgios.ClusteringAlgorithms
Class KMeans2
- java.lang.Object
-
- medusa.georgios.ClusteringAlgorithms.KMeans2
-
public class KMeans2 extends java.lang.ObjectImplements the k-means algorithm
-
-
Constructor Summary
Constructors Constructor and Description KMeans2(int k, BasicGraph g)KMeans2(int k, java.util.List kMeansPoints)Returns a new instance of kMeans algorithmKMeans2(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.georgios.ClusteringAlgorithms.clustergetCluster(int index)Returns the specified cluster by indexjava.util.Map<java.lang.String,java.lang.Integer>getClusterMap()java.util.VectorgetDataPoints()Returns the data pointsintgetK()Returns the value of kjava.lang.StringgetReport()intgetSmallestClusterSize()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.StringSave_To_File(java.lang.String filename)voidSave_To_File(java.lang.String filename, java.lang.String information)java.lang.StringtoString()Returns the string output of the data points
-
-
-
Constructor Detail
-
KMeans2
public KMeans2(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
-
KMeans2
public KMeans2(int k, BasicGraph g)
-
KMeans2
public KMeans2(int k, java.util.List 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
-
runKMeans
public void runKMeans()
Runs the k-means algorithm over the data set
-
Save_To_File
public java.lang.String Save_To_File(java.lang.String filename)
-
getK
public int getK()
Returns the value of k- Returns:
- the value of k
-
getCluster
public medusa.georgios.ClusteringAlgorithms.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()
-
getReport
public java.lang.String getReport()
-
Save_To_File
public void Save_To_File(java.lang.String filename, java.lang.String information)
-
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