[mlpack-git] master: Refactor to avoid issues with empty cluster action refactoring. (0495b6b)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Mon Jun 1 11:16:07 EDT 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/803224f64f6b6490c3cb8aafd528b1db069ef2f1...7011dd89f6a9cf8cf7b66e1b42c9147b606551c2

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

commit 0495b6bfb8a1ee21cd02fd8271d03959da4c0260
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Jun 1 11:15:26 2015 -0400

    Refactor to avoid issues with empty cluster action refactoring.


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

0495b6bfb8a1ee21cd02fd8271d03959da4c0260
 src/mlpack/methods/kmeans/refined_start_impl.hpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mlpack/methods/kmeans/refined_start_impl.hpp b/src/mlpack/methods/kmeans/refined_start_impl.hpp
index edceb11..4130764 100644
--- a/src/mlpack/methods/kmeans/refined_start_impl.hpp
+++ b/src/mlpack/methods/kmeans/refined_start_impl.hpp
@@ -33,7 +33,6 @@ void RefinedStart::Cluster(const MatType& data,
   // We will use these objects repeatedly for clustering.
   arma::Col<size_t> sampledAssignments;
   arma::mat centroids;
-  KMeans<> kmeans;
 
   for (size_t i = 0; i < samplings; ++i)
   {
@@ -57,6 +56,7 @@ void RefinedStart::Cluster(const MatType& data,
     // cluster, we re-initialize that cluster as the point furthest away from
     // the cluster with maximum variance.  This is not *exactly* what the paper
     // implements, but it is quite similar, and we'll call it "good enough".
+    KMeans<> kmeans;
     kmeans.Cluster(sampledData, clusters, sampledAssignments, centroids);
 
     // Store the sampled centroids.
@@ -66,6 +66,7 @@ void RefinedStart::Cluster(const MatType& data,
   }
 
   // Now, we run k-means on the sampled centroids to get our final clusters.
+  KMeans<> kmeans;
   kmeans.Cluster(sampledCentroids, clusters, sampledAssignments, centroids);
 
   // Turn the final centroids into assignments.



More information about the mlpack-git mailing list