DataType - The type of the data to cluster. This is typically
defined by the divergence function used.@CodeReview(reviewer="Kevin R. Dixon", date="2008-07-22", changesNeeded=false, comments={"Added PublicationReference","Code generally looks fine."}) @PublicationReference(author="C. Elkan", title="Using the Triangle Inequality to Accelerate k-Means", type=Conference, year=2003, publication="Proceedings of the Twentieth International Conference on Machine Learning", pages={147,153}, url="www-cse.ucsd.edu/~elkan/kmeansicml03.pdf") public class OptimizedKMeansClusterer<DataType> extends KMeansClusterer<DataType,CentroidCluster<DataType>>
| Modifier and Type | Field and Description |
|---|---|
protected double[][] |
clusterDistances
The distances between clusters.
|
protected double[][] |
lowerBounds
The lower bounds on the distances to the clusters.
|
protected double[] |
upperBounds
The upper bounds on the distance to the current assigned cluster.
|
assignments, clusterCounts, clusters, DEFAULT_MAX_ITERATIONS, DEFAULT_NUM_REQUESTED_CLUSTERS, divergenceFunction, initializer, numRequestedClustersdata, keepGoingmaxIterationsDEFAULT_ITERATION, iteration| Constructor and Description |
|---|
OptimizedKMeansClusterer(int numClusters,
int maxIterations,
FixedClusterInitializer<CentroidCluster<DataType>,DataType> initializer,
Metric<? super DataType> metric,
ClusterCreator<CentroidCluster<DataType>,DataType> creator)
Creates a new instance of OptimizedKMeansClusterer.
|
| Modifier and Type | Method and Description |
|---|---|
OptimizedKMeansClusterer<DataType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
protected void |
computeClusterDistances()
Computes the distances between the clusters.
|
DataType |
getClusterCentroid(int clusterIndex)
Gets the centroid for the given cluster index.
|
Metric<? super DataType> |
getMetric()
Gets the metric being used by the algorithm.
|
protected boolean |
initializeAlgorithm()
Called to initialize the learning algorithm's state based on the
data that is stored in the data field.
|
protected boolean |
step()
Do a step of the clustering algorithm.
|
assignDataFromIndices, assignDataToClusters, cleanupAlgorithm, createClustersFromAssignments, getAssignments, getClosestClusterIndex, getCluster, getClusterCounts, getClusters, getCreator, getDivergenceFunction, getInitializer, getNumChanged, getNumClusters, getNumElements, getNumRequestedClusters, getPerformance, getResult, setAssignment, setClusters, setCreator, setData, setDivergenceFunction, setInitializer, setNumChanged, setNumRequestedClustersgetData, getKeepGoing, learn, setKeepGoing, stopgetMaxIterations, isResultValid, setMaxIterationsaddIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListenersequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitlearngetMaxIterations, setMaxIterationsaddIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListenerisResultValidprotected double[][] lowerBounds
protected double[] upperBounds
protected double[][] clusterDistances
public OptimizedKMeansClusterer(int numClusters,
int maxIterations,
FixedClusterInitializer<CentroidCluster<DataType>,DataType> initializer,
Metric<? super DataType> metric,
ClusterCreator<CentroidCluster<DataType>,DataType> creator)
numClusters - The number of clusters to create.maxIterations - Number of iterations before stoppinginitializer - The cluster initializer.metric - The metric to use.creator - The cluster creator to use.public OptimizedKMeansClusterer<DataType> clone()
AbstractCloneableSerializableObject class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone() to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone() as the basis for your implementation.clone in interface CloneableSerializableclone in class KMeansClusterer<DataType,CentroidCluster<DataType>>protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearnerinitializeAlgorithm in class KMeansClusterer<DataType,CentroidCluster<DataType>>protected void computeClusterDistances()
protected boolean step()
KMeansClustererstep in class KMeansClusterer<DataType,CentroidCluster<DataType>>public DataType getClusterCentroid(int clusterIndex)
clusterIndex - The index of the cluster to get the centroid for.