[mlpack-git] master: Style fixes for main file. Also give a bit of informational output when running. (8612608)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Wed Apr 29 14:43:45 EDT 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/ee384655c4462e422e343e9725437fd772ca4449...182d4a629c1b23f683dff7b284844e4e3e9f5cc4

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

commit 861260890e3fc2a3eb1d3310fd231f80db5a994f
Author: Ryan Curtin <ryan at ratml.org>
Date:   Fri Mar 27 17:15:52 2015 +0000

    Style fixes for main file. Also give a bit of informational output when running.


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

861260890e3fc2a3eb1d3310fd231f80db5a994f
 src/mlpack/methods/mean_shift/mean_shift_main.cpp | 39 +++++++++++++----------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/src/mlpack/methods/mean_shift/mean_shift_main.cpp b/src/mlpack/methods/mean_shift/mean_shift_main.cpp
index c53d29f..fb2fb27 100644
--- a/src/mlpack/methods/mean_shift/mean_shift_main.cpp
+++ b/src/mlpack/methods/mean_shift/mean_shift_main.cpp
@@ -11,6 +11,7 @@
 
 using namespace mlpack;
 using namespace mlpack::meanshift;
+using namespace mlpack::kernel;
 using namespace std;
 
 // Define parameters for the executable.
@@ -43,8 +44,8 @@ PARAM_DOUBLE("radius", "If distance of two centroids is less than radius "
              "Points with distance to current centroid less than radius "
              "will be used to calculate new centroid. ", "r", 0);
 
-int main(int argc, char** argv) {
-  
+int main(int argc, char** argv)
+{
   CLI::ParseCommandLine(argc, argv);
 
   const string inputFile = CLI::GetParam<string>("inputFile");
@@ -52,16 +53,18 @@ int main(int argc, char** argv) {
   const double bandwidth = CLI::GetParam<double>("bandwidth");
   const int maxIterations = CLI::GetParam<int>("max_iterations");
 
-  if (maxIterations < 0) {
+  if (maxIterations < 0)
+  {
     Log::Fatal << "Invalid value for maximum iterations (" << maxIterations <<
-    ")! Must be greater than or equal to 0." << endl;
+        ")! Must be greater than or equal to 0." << endl;
   }
 
   // Make sure we have an output file if we're not doing the work in-place.
   if (!CLI::HasParam("in_place") && !CLI::HasParam("output_file") &&
-      !CLI::HasParam("centroid_file")) {
+      !CLI::HasParam("centroid_file"))
+  {
     Log::Warn << "--output_file, --in_place, and --centroid_file are not set; "
-    << "no results will be saved." << std::endl;
+        << "no results will be saved." << endl;
   }
 
   arma::mat dataset;
@@ -69,16 +72,21 @@ int main(int argc, char** argv) {
   arma::mat centroids;
   arma::Col<size_t> assignments;
 
-  kernel::GaussianKernel kernel(bandwidth);
+  GaussianKernel kernel(bandwidth);
 
   MeanShift<> meanShift(radius, maxIterations, kernel);
+
   Timer::Start("clustering");
+  Log::Info << "Performing mean shift clustering..." << endl;
   meanShift.Cluster(dataset, assignments, centroids);
   Timer::Stop("clustering");
 
-  if (CLI::HasParam("in_place")) {
-    // Add the column of assignments to the dataset; but we have to convert
-    // them to type double first.
+  Log::Info << "Found " << centroids.n_cols << " centroids." << endl;
+
+  if (CLI::HasParam("in_place"))
+  {
+    // Add the column of assignments to the dataset; but we have to convert them
+    // to type double first.
     arma::vec converted(assignments.n_elem);
     for (size_t i = 0; i < assignments.n_elem; i++)
       converted(i) = (double) assignments(i);
@@ -87,8 +95,9 @@ int main(int argc, char** argv) {
 
     // Save the dataset.
     data::Save(inputFile, dataset);
-  } else {
-    
+  }
+  else
+  {
     // Convert the assignments to doubles.
     arma::vec converted(assignments.n_elem);
     for (size_t i = 0; i < assignments.n_elem; i++)
@@ -99,13 +108,9 @@ int main(int argc, char** argv) {
     // Now save, in the different file.
     string outputFile = CLI::GetParam<string>("output_file");
     data::Save(outputFile, dataset);
-
   }
 
   // Should we write the centroids to a file?
-  if (CLI::HasParam("centroid_file")) {
+  if (CLI::HasParam("centroid_file"))
     data::Save(CLI::GetParam<std::string>("centroid_file"), centroids);
-  }
-  
-  
 }



More information about the mlpack-git mailing list