Update tutorial to discuss empty clusters and LloydStepType.
This commit is contained in:
@@ -653,11 +653,13 @@ The \c LloydStepType policy also mandates three functions:
|
||||
@code
|
||||
/**
|
||||
* Run a single iteration of the Lloyd algorithm, updating the given centroids
|
||||
* into the newCentroids matrix.
|
||||
* into the newCentroids matrix. If any cluster is empty (that is, if any
|
||||
* cluster has no points assigned to it), then the centroid associated with
|
||||
* that cluster may be filled with invalid data (it will be corrected later).
|
||||
*
|
||||
* @param centroids Current cluster centroids.
|
||||
* @param newCentroids New cluster centroids.
|
||||
* @param counts Counts of the number of points in each cluster.
|
||||
* @param counts Number of points in each cluster at the end of the iteration.
|
||||
*/
|
||||
double Iterate(const arma::mat& centroids,
|
||||
arma::mat& newCentroids,
|
||||
@@ -670,6 +672,10 @@ double Iterate(const arma::mat& centroids,
|
||||
size_t DistanceCalculations() const { return distanceCalculations; }
|
||||
@endcode
|
||||
|
||||
Note that \c Iterate() does not need to return valid centroids if the cluster is
|
||||
empty. This is because \c EmptyClusterPolicy will handle the empty centroid.
|
||||
This behavior can be used to avoid small amounts of computation.
|
||||
|
||||
For examples, see the five aforementioned implementations of classes that
|
||||
satisfy the \c LloydStepType policy.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user