[mlpack-svn] r12281 - mlpack/trunk/src/mlpack/methods/kmeans

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Apr 10 11:15:22 EDT 2012


Author: rcurtin
Date: 2012-04-10 11:15:22 -0400 (Tue, 10 Apr 2012)
New Revision: 12281

Modified:
   mlpack/trunk/src/mlpack/methods/kmeans/kmeans_impl.hpp
Log:
Use Log::Debug instead of cout for debugging output (maybe it should be Info?).
Also needlessly replace '\n' with std::endl -- really, there's no reason to do
this; I just did it.


Modified: mlpack/trunk/src/mlpack/methods/kmeans/kmeans_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/kmeans/kmeans_impl.hpp	2012-04-10 09:01:49 UTC (rev 12280)
+++ mlpack/trunk/src/mlpack/methods/kmeans/kmeans_impl.hpp	2012-04-10 15:15:22 UTC (rev 12281)
@@ -83,7 +83,7 @@
 
   // Build the mrkd-tree on this dataset
   tree::BinarySpaceTree<typename bound::HRectBound<2>, tree::MRKDStatistic> tree(data, 1);
-  std::cout << "Tree Built \n";
+  Log::Debug << "Tree Built." << std::endl;
   // A pointer for traversing the mrkd-tree
   tree::BinarySpaceTree<typename bound::HRectBound<2>, tree::MRKDStatistic>* node;
 
@@ -113,7 +113,7 @@
   MatType newCentroids(dimensionality, centroids.n_cols);
 
   // Create a stack for traversing the mrkd-tree
-  std::stack<typename tree::BinarySpaceTree<typename bound::HRectBound<2>, 
+  std::stack<typename tree::BinarySpaceTree<typename bound::HRectBound<2>,
                                             tree::MRKDStatistic>* > stack;
 
   // A variable to keep track of how many kmeans iterations we have made
@@ -132,7 +132,7 @@
 
   // A variable to keep track of how often we stop at a parent node
   size_t dominations = 0;
-  do 
+  do
   {
     // Keep track of what iteration we are on.
     ++iteration;
@@ -224,7 +224,7 @@
         // Calculate the center of mass of this hyperrectangle
         arma::vec center = mrkd.centerOfMass / mrkd.count;
 
-        // Set the minDistance to the maximum value of a double so any value 
+        // Set the minDistance to the maximum value of a double so any value
         // must be smaller than this
         double minDistance = std::numeric_limits<double>::max();
 
@@ -483,7 +483,10 @@
     // assignments
   } while (changedAssignments > 0 && iteration != maxIterations);
 
-  std::cout << "Iterations: " << iteration << '\t' << "Skips: " << skip << '\t' << "Comparisons: " << comps << '\t' << "Dominations: " << dominations << '\n';
+  Log::Debug << "Iterations: " << iteration << std::endl
+      << "Skips: " << skip << std::endl
+      << "Comparisons: " << comps << std::endl
+      << "Dominations: " << dominations << std::endl;
 }
 
 /**
@@ -591,8 +594,9 @@
     iteration++;
 
   } while (changedAssignments > 0 && iteration != maxIterations);
-  std::cout << "Iterations: " << iteration << std::endl;
 
+  Log::Debug << "Iterations: " << iteration << std::endl;
+
   // If we have overclustered, we need to merge the nearest clusters.
   if (actualClusters != clusters)
   {
@@ -684,7 +688,7 @@
 
       // Now max the distances for the second cluster (which no longer has
       // anything in it).
-      offset = (size_t) (((actualClusters - 1) * second) 
+      offset = (size_t) (((actualClusters - 1) * second)
 			 + (second - pow(second, 2.0)) / 2) - 1;
       for (size_t cluster = second + 1; cluster < actualClusters; cluster++)
         distances(offset + (cluster - second)) = DBL_MAX;




More information about the mlpack-svn mailing list