[mlpack] 09/40: Handle an edge case when all the points are the same.

Barak A. Pearlmutter barak+git at pearlmutter.net
Mon Feb 15 19:34:22 UTC 2016


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch master
in repository mlpack.

commit 41ca156406bc07298e30615ef805b95a09bbf919
Author: Ryan Curtin <ryan at ratml.org>
Date:   Wed Jan 13 11:11:49 2016 -0500

    Handle an edge case when all the points are the same.
---
 src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp | 5 +++++
 1 file changed, 5 insertions(+)

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 5b2b252..ba9a0da 100644
--- a/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp
+++ b/src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp
@@ -41,6 +41,11 @@ size_t MaxVarianceNewCluster::EmptyCluster(const MatType& data,
   arma::uword maxVarCluster = 0;
   variances.max(maxVarCluster);
 
+  // If the cluster with maximum variance has variance of 0, then we can't
+  // continue.  All the points are the same.
+  if (variances[maxVarCluster] == 0.0)
+    return 0;
+
   // Now, inside this cluster, find the point which is furthest away.
   size_t furthestPoint = data.n_cols;
   double maxDistance = -DBL_MAX;

-- 
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