[mlpack] 18/324: Don't select points from clusters of size 1.
Barak A. Pearlmutter
barak+git at cs.nuim.ie
Sun Aug 17 08:21:52 UTC 2014
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch svn-trunk
in repository mlpack.
commit f4ab5bb379af85d99a292013d224e06570d6d7c1
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date: Fri May 23 16:03:41 2014 +0000
Don't select points from clusters of size 1.
git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16545 9d5b8971-822b-0410-80eb-d18c1038ef23
---
src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp b/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp
index e8408a4..c97ef71 100644
--- a/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp
+++ b/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp
@@ -37,8 +37,12 @@ size_t MaxVarianceNewCluster::EmptyCluster(const MatType& data,
}
// 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;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list