[mlpack-svn] r16545 - mlpack/trunk/src/mlpack/methods/kmeans
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri May 23 12:03:42 EDT 2014
Author: rcurtin
Date: Fri May 23 12:03:41 2014
New Revision: 16545
Log:
Don't select points from clusters of size 1.
Modified:
mlpack/trunk/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp
Modified: mlpack/trunk/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp (original)
+++ mlpack/trunk/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp Fri May 23 12:03:41 2014
@@ -37,8 +37,12 @@
}
// Divide by the number of points in the cluster to produce the variance.
+ // Although a -nan will occur here for the empty cluster(s), this doesn't
+ // matter because variances.max() won't pick it up. If the number of points
+ // in the cluster is 1, we ensure that cluster is not selected by forcing the
+ // variance to 0.
for (size_t i = 0; i < clusterCounts.n_elem; ++i)
- variances[i] /= clusterCounts[i];
+ variances[i] /= (clusterCounts[i] == 1) ? DBL_MAX : clusterCounts[i];
// Now find the cluster with maximum variance.
arma::uword maxVarCluster;
More information about the mlpack-svn
mailing list