|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.SwingWorker<java.lang.Void,java.lang.Void>
it.unibz.algorithms.KMeans
public class KMeans
This class represents the KMeans algorithm in all its iterative steps Extends SwingWorker in order to be executed as a background Thread and to keep control of progress.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.SwingWorker |
---|
javax.swing.SwingWorker.StateValue |
Field Summary | |
---|---|
private boolean |
clearnoise
|
private static java.util.List<Cluster> |
clusters
|
private java.util.Vector<Instance> |
instances
|
private int |
numberiterations
|
Constructor Summary | |
---|---|
KMeans(int k,
int iter,
java.util.Vector<Instance> instances,
boolean clearnoise)
Base constructor initializes the needed Clusters |
Method Summary | |
---|---|
protected java.lang.Void |
doInBackground()
Executes the main Kmeans algorithm composed by various steps Note: The various isCancelled() are used to proper stop this thread if the user closes the operation. |
private Centroid |
generateCentroid(int currentpos)
Method generates the first centroids used to perform initial steps |
java.util.List<Cluster> |
getClusters()
Method returns all Clusters to be printed out |
private void |
initializeCentroids()
Method used to complete step 1 of the Kmeans algorithm. |
private void |
randomAssign()
Method is used for step 2. |
private void |
refreshCentroids()
Method refreshes all clusters centroid |
Methods inherited from class javax.swing.SwingWorker |
---|
addPropertyChangeListener, cancel, done, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgress |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static java.util.List<Cluster> clusters
private int numberiterations
private boolean clearnoise
private java.util.Vector<Instance> instances
Constructor Detail |
---|
public KMeans(int k, int iter, java.util.Vector<Instance> instances, boolean clearnoise)
Method Detail |
---|
private void initializeCentroids()
private Centroid generateCentroid(int currentpos)
currentpos
- Is the current position of the loop
protected java.lang.Void doInBackground() throws java.lang.Exception
doInBackground
in class javax.swing.SwingWorker<java.lang.Void,java.lang.Void>
java.lang.Exception
private void refreshCentroids()
private void randomAssign()
public java.util.List<Cluster> getClusters()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |