[mlpack-git] master: Add a warning if the user wants 0 clusters, because the thing is probably going to crash (but maybe for some LloydIterationType that might be what's desired?). (18a22c1)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:00:56 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

>---------------------------------------------------------------

commit 18a22c12ef26ac160f28f74e29a548b8d5127d85
Author: Ryan Curtin <ryan at ratml.org>
Date:   Fri Oct 10 19:19:10 2014 +0000

    Add a warning if the user wants 0 clusters, because the thing is probably going
    to crash (but maybe for some LloydIterationType that might be what's desired?).


>---------------------------------------------------------------

18a22c12ef26ac160f28f74e29a548b8d5127d85
 src/mlpack/methods/kmeans/kmeans_impl.hpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/mlpack/methods/kmeans/kmeans_impl.hpp b/src/mlpack/methods/kmeans/kmeans_impl.hpp
index 87b42b2..7b8d9a3 100644
--- a/src/mlpack/methods/kmeans/kmeans_impl.hpp
+++ b/src/mlpack/methods/kmeans/kmeans_impl.hpp
@@ -89,6 +89,9 @@ Cluster(const MatType& data,
   if (clusters > data.n_cols)
     Log::Warn << "KMeans::Cluster(): more clusters requested than points given."
         << std::endl;
+  else if (clusters == 0)
+    Log::Warn << "KMeans::Cluster(): zero clusters requested.  This probably "
+        << "isn't going to work.  Brace for crash." << std::endl;
 
   // Check validity of initial guess.
   if (initialGuess)



More information about the mlpack-git mailing list