[mlpack-svn] r10069 - in mlpack/trunk/src/mlpack/methods: . emst fastica infomax_ica linear_regression mog mvu naive_bayes nca neighbor_search nnsvm regression svm

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Sat Oct 29 00:26:39 EDT 2011


Author: rcurtin
Date: 2011-10-29 00:26:38 -0400 (Sat, 29 Oct 2011)
New Revision: 10069

Modified:
   mlpack/trunk/src/mlpack/methods/CMakeLists.txt
   mlpack/trunk/src/mlpack/methods/emst/emst_main.cpp
   mlpack/trunk/src/mlpack/methods/fastica/fastica_main.cpp
   mlpack/trunk/src/mlpack/methods/fastica/lin_alg_test.cpp
   mlpack/trunk/src/mlpack/methods/infomax_ica/infomax_ica_test.cc
   mlpack/trunk/src/mlpack/methods/infomax_ica/main.cc
   mlpack/trunk/src/mlpack/methods/linear_regression/linear_regression_main.cpp
   mlpack/trunk/src/mlpack/methods/mog/mog_em_main.cc
   mlpack/trunk/src/mlpack/methods/mog/mog_l2e_main.cc
   mlpack/trunk/src/mlpack/methods/mvu/CMakeLists.txt
   mlpack/trunk/src/mlpack/methods/mvu/mvu.h
   mlpack/trunk/src/mlpack/methods/mvu/mvu_impl.h
   mlpack/trunk/src/mlpack/methods/mvu/mvu_objective_function.h
   mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_main.cc
   mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_test.cc
   mlpack/trunk/src/mlpack/methods/nca/nca_main.cc
   mlpack/trunk/src/mlpack/methods/nca/nca_softmax_error_function.h
   mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_main.cc
   mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_test.cc
   mlpack/trunk/src/mlpack/methods/neighbor_search/allknn_main.cc
   mlpack/trunk/src/mlpack/methods/neighbor_search/allknn_test.cc
   mlpack/trunk/src/mlpack/methods/nnsvm/nnsvm_main.cpp
   mlpack/trunk/src/mlpack/methods/regression/ridge_main.cc
   mlpack/trunk/src/mlpack/methods/svm/svm_main.cc
Log:
Use overloaded mat.save() and mat.load() functions.


Modified: mlpack/trunk/src/mlpack/methods/CMakeLists.txt
===================================================================
--- mlpack/trunk/src/mlpack/methods/CMakeLists.txt	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/CMakeLists.txt	2011-10-29 04:26:38 UTC (rev 10069)
@@ -9,7 +9,7 @@
   # kernel_pca # (required sparse and is known to not work or compile)
   linear_regression
   mog
-  # mvu  # (currently known to not work)
+  mvu  # (currently known to not work)
   naive_bayes
   nca
   neighbor_search

Modified: mlpack/trunk/src/mlpack/methods/emst/emst_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/emst/emst_main.cpp	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/emst/emst_main.cpp	2011-10-29 04:26:38 UTC (rev 10069)
@@ -143,7 +143,8 @@
       std::string naive_output_filename =
           CLI::GetParam<std::string>("naive/output_file");
 
-      naive_results.save(naive_output_filename.c_str());
+      naive_results.save(naive_output_filename.c_str(), arma::csv_ascii, false,
+          true);
     }
 
     //////////////// Output the Results ////////////////
@@ -151,7 +152,7 @@
     std::string output_filename =
         CLI::GetParam<std::string>("emst/output_file");
 
-    results.save(output_filename.c_str());
+    results.save(output_filename.c_str(), arma::csv_ascii, false, true);
 
   }// end else (if using_thor)
 

Modified: mlpack/trunk/src/mlpack/methods/fastica/fastica_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/fastica/fastica_main.cpp	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/fastica/fastica_main.cpp	2011-10-29 04:26:38 UTC (rev 10069)
@@ -57,7 +57,7 @@
 
   CLI::ParseCommandLine(argc, argv);
   const char* data = CLI::GetParam<std::string>("fastica/input_file").c_str();
-  X.load(data);
+  X.load(data, arma::auto_detect, false, true);
 
   const char* ic_filename = CLI::GetParam<std::string>("fastica/ic_file").c_str();
   const char* unmixing_filename =
@@ -69,9 +69,9 @@
   if(fastica.Init(X) == true) {
     arma::mat W, Y;
     if(fastica.DoFastICA(W, Y) == true) {
-      Y.save(ic_filename);
+      Y.save(ic_filename, arma::csv_ascii, false, true);
       arma::mat Z = trans(W);
-      Z.save(unmixing_filename);
+      Z.save(unmixing_filename, arma::csv_ascii, false, true);
       success_status = true;
       mlpack::Log::Debug << W << std::endl;
     }

Modified: mlpack/trunk/src/mlpack/methods/fastica/lin_alg_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/fastica/lin_alg_test.cpp	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/fastica/lin_alg_test.cpp	2011-10-29 04:26:38 UTC (rev 10069)
@@ -84,7 +84,7 @@
   // We are loading a matrix from an external file... bad choice.
   mat tmp, tmp_centered, whitened, whitening_matrix;
 
-  tmp.load("fake.arff");
+  tmp.load("trainSet.csv", arma::auto_detect, false, true);
   Center(tmp, tmp_centered);
   WhitenUsingEig(tmp_centered, whitened, whitening_matrix);
 
@@ -107,7 +107,7 @@
   // Generate a random matrix; then, orthogonalize it and test if it's
   // orthogonal.
   mat tmp, orth;
-  tmp.load("fake.arff");
+  tmp.load("fake.csv", arma::auto_detect, false, true);
   Orthogonalize(tmp, orth);
 
   // test orthogonality

Modified: mlpack/trunk/src/mlpack/methods/infomax_ica/infomax_ica_test.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/infomax_ica/infomax_ica_test.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/infomax_ica/infomax_ica_test.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -22,7 +22,7 @@
   int bb_ = 5;
   double epsilonb_ = 0.001;
 
-  testdatab_.load("fake.arff");
+  testdatab_.load("fake.csv", arma::auto_detect, false, true);
 
   InfomaxICA icab_(lambdab_, bb_, epsilonb_);
 
@@ -39,7 +39,7 @@
 
   // load some test data that has been verified using the matlab
   // implementation of infomax
-  testdata_.load("fake.arff");
+  testdata_.load("fake.csv", arma::auto_detect, false, true);
 
   InfomaxICA ica_(lambda_, b_, epsilon_);
   ica_.sampleCovariance(testdata_);
@@ -53,7 +53,7 @@
 
   // load some test data that has been verified using the matlab
   // implementation of infomax
-  testdata_.load("fake.arff");
+  testdata_.load("fake.csv", arma::auto_detect, false, true);
 
   InfomaxICA ica_(lambda_, b_, epsilon_);
   arma::mat unmixing;

Modified: mlpack/trunk/src/mlpack/methods/infomax_ica/main.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/infomax_ica/main.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/infomax_ica/main.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -22,7 +22,7 @@
   double epsilon = CLI::GetParam<double>("info/epsilon");
 
   arma::mat dataset;
-  dataset.load(data_file_name);
+  dataset.load(data_file_name, arma::auto_detect, false, true);
 
   InfomaxICA ica(lambda, B, epsilon);
   ica.applyICA(dataset);

Modified: mlpack/trunk/src/mlpack/methods/linear_regression/linear_regression_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/linear_regression/linear_regression_main.cpp	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/linear_regression/linear_regression_main.cpp	2011-10-29 04:26:38 UTC (rev 10069)
@@ -29,9 +29,9 @@
   const std::string response_name =
     CLI::GetParam<std::string>("linear_regression/responses");
 
-  file.load(train_name.c_str());
+  file.load(train_name.c_str(), arma::auto_detect, false, true);
   size_t n_cols = file.n_cols,
-	 n_rows = file.n_rows;
+         n_rows = file.n_rows;
 
   if(response_name == "") {
     predictors = file.submat(0,0, n_rows-2, n_cols-1);
@@ -42,7 +42,7 @@
   else {
     predictors = file;
     // The initial predictors for y, Nx1
-    responses.load(response_name.c_str());
+    responses.load(response_name.c_str(), arma::auto_detect, false, true);
     if(responses.n_rows > 1) {
       std::cerr << "Error: The responses must have one column.\n";
       return 0;
@@ -54,7 +54,7 @@
     }
   }
 
-  points.load(test_name.c_str());
+  points.load(test_name.c_str(), arma::auto_detect, false, true);
   if(points.n_rows != n_rows) {
       std::cerr << "Error: The test data must have the same number of cols as\
  the training file.\n";

Modified: mlpack/trunk/src/mlpack/methods/mog/mog_em_main.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/mog/mog_em_main.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/mog/mog_em_main.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -39,7 +39,8 @@
 
   ////// READING PARAMETERS AND LOADING DATA //////
   arma::mat data_points;
-  data_points.load(CLI::GetParam<std::string>("mog/data").c_str());
+  data_points.load(CLI::GetParam<std::string>("mog/data").c_str(),
+      arma::auto_detect, false, true);
 
   ////// MIXTURE OF GAUSSIANS USING EM //////
   MoGEM mog;

Modified: mlpack/trunk/src/mlpack/methods/mog/mog_l2e_main.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/mog/mog_l2e_main.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/mog/mog_l2e_main.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -40,7 +40,8 @@
 
   ////// READING PARAMETERS AND LOADING DATA //////
   arma::mat data_points;
-  data_points.load(CLI::GetParam<std::string>("mog_l2e/data").c_str());
+  data_points.load(CLI::GetParam<std::string>("mog_l2e/data").c_str(),
+      arma::auto_detect, false, true);
 
   ////// MIXTURE OF GAUSSIANS USING L2 ESTIMATCLIN //////
   size_t number_of_gaussians = CLI::GetParam<int>("mog_l2e/k");

Modified: mlpack/trunk/src/mlpack/methods/mvu/CMakeLists.txt
===================================================================
--- mlpack/trunk/src/mlpack/methods/mvu/CMakeLists.txt	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/mvu/CMakeLists.txt	2011-10-29 04:26:38 UTC (rev 10069)
@@ -5,8 +5,8 @@
 set(SOURCES
   mvu.h
   mvu_impl.h
-  mvu_objective_function.h
-  mvu_objective_function.cc
+#  mvu_objective_function.h
+#  mvu_objective_function.cc
 )
 
 # Add directory name to sources.
@@ -19,7 +19,7 @@
 set(MLPACK_SRCS ${MLPACK_SRCS} ${DIR_SRCS} PARENT_SCOPE)
 
 add_executable(ncmvu
-  main.cc
+  mvu_main.cpp
 )
 target_link_libraries(ncmvu
   mlpack

Modified: mlpack/trunk/src/mlpack/methods/mvu/mvu.h
===================================================================
--- mlpack/trunk/src/mlpack/methods/mvu/mvu.h	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/mvu/mvu.h	2011-10-29 04:26:38 UTC (rev 10069)
@@ -11,8 +11,7 @@
 #ifndef __MLPACK_MVU_H
 #define __MLPACK_MVU_H
 
-#include <fastlib/fastlib.h>
-#include <armadillo>
+#include <mlpack/core.h>
 
 namespace mlpack {
 namespace mvu {

Modified: mlpack/trunk/src/mlpack/methods/mvu/mvu_impl.h
===================================================================
--- mlpack/trunk/src/mlpack/methods/mvu/mvu_impl.h	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/mvu/mvu_impl.h	2011-10-29 04:26:38 UTC (rev 10069)
@@ -8,7 +8,7 @@
 #ifndef __MLPACK_MVU_IMPL_H
 #define __MLPACK_MVU_IMPL_H
 
-#include <fastlib/optimization/aug_lagrangian/aug_lagrangian.h>
+#include <mlpack/core/optimizers/aug_lagrangian/aug_lagrangian.hpp>
 
 namespace mlpack {
 namespace mvu {

Modified: mlpack/trunk/src/mlpack/methods/mvu/mvu_objective_function.h
===================================================================
--- mlpack/trunk/src/mlpack/methods/mvu/mvu_objective_function.h	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/mvu/mvu_objective_function.h	2011-10-29 04:26:38 UTC (rev 10069)
@@ -22,8 +22,7 @@
 #ifndef __MLPACK_MVU_OBJECTIVE_FUNCTCLIN_H
 #define __MLPACK_MVU_OBJECTIVE_FUNCTCLIN_H
 
-#include <fastlib/fastlib.h>
-#include <armadillo>
+#include <mlpack/core.h>
 
 namespace mlpack {
 namespace mvu {
@@ -42,7 +41,7 @@
  *
  * max (R * R^T) subject to
  *  (1) sum (R * R^T) = 0
- *  (2) (R R^T)_ii - 2 (R R^T)_ij + (R R^T)_jj = || x_i - x_j ||^2 ; 
+ *  (2) (R R^T)_ii - 2 (R R^T)_ij + (R R^T)_jj = || x_i - x_j ||^2 ;
  *        for all (i, j) nearest neighbors
  *
  * Now, our optimization problem is easier.  The total number of constraints is

Modified: mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_main.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_main.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_main.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -78,11 +78,11 @@
 
   const char *training_data_filename = CLI::GetParam<std::string>("nbc/train").c_str();
   arma::mat training_data;
-  training_data.load(training_data_filename);
+  training_data.load(training_data_filename, arma::auto_detect, false, true);
 
   const char *testing_data_filename = CLI::GetParam<std::string>("nbc/test").c_str();
   arma::mat testing_data;
-  testing_data.load(testing_data_filename);
+  testing_data.load(testing_data_filename, arma::auto_detect, false, true);
 
   ////// SIMPLE NAIVE BAYES CLASSIFICATCLIN ASSUMING THE DATA TO BE UNIFORMLY DISTRIBUTED //////
 
@@ -110,7 +110,7 @@
   ////// OUTPUT RESULTS //////
   std::string output_filename = CLI::GetParam<std::string>("nbc/output");
 
-  results.save(output_filename.c_str());
+  results.save(output_filename.c_str(), arma::csv_ascii, false, true);
 
   return 1;
 }

Modified: mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_test.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_test.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_test.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -8,15 +8,15 @@
 using namespace naive_bayes;
 
 BOOST_AUTO_TEST_CASE(SimpleNBCTest) {
-  const char* filename_train_ = "trainSet.arff";
-  const char* filename_test_ = "testSet.arff";
-  const char* train_result_ = "trainRes.arff";
-  const char* test_result_ = "testRes.arff";
+  const char* filename_train_ = "trainSet.csv";
+  const char* filename_test_ = "testSet.csv";
+  const char* train_result_ = "trainRes.csv";
+  const char* test_result_ = "testRes.csv";
   size_t number_of_classes_ = 2;
 
   arma::mat train_data, train_res, calc_mat;
-  train_data.load(filename_train_, arma::auto_detect, true, true);
-  train_res.load(train_result_, arma::auto_detect, true, true);
+  train_data.load(filename_train_, arma::auto_detect, false, true);
+  train_res.load(train_result_, arma::auto_detect, false, true);
 
   CLI::GetParam<int>("nbc/classes") = number_of_classes_;
   SimpleNaiveBayesClassifier nbc_test_(train_data);
@@ -41,8 +41,9 @@
 
   arma::mat test_data, test_res;
   arma::vec test_res_vec, calc_vec;
-  test_data.load(filename_test_, arma::auto_detect, true, true);
-  test_res.load(test_result_, arma::auto_detect, true, true);
+  test_data.load(filename_test_, arma::auto_detect, false, true);
+  test_res.load(test_result_, arma::auto_detect, false, true);
+
   nbc_test_.Classify(test_data, calc_vec);
 
   size_t number_of_datum = test_data.n_cols;

Modified: mlpack/trunk/src/mlpack/methods/nca/nca_main.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/nca/nca_main.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/nca/nca_main.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -25,7 +25,8 @@
   CLI::ParseCommandLine(argc, argv);
 
   arma::mat data;
-  data.load(CLI::GetParam<string>("input_file").c_str());
+  data.load(CLI::GetParam<string>("input_file").c_str(), arma::auto_detect,
+      false, true);
 
   arma::uvec labels(data.n_cols);
   for (size_t i = 0; i < data.n_cols; i++)
@@ -39,5 +40,6 @@
 
   nca.LearnDistance(distance);
 
-  distance.save(CLI::GetParam<string>("output_file").c_str());
+  distance.save(CLI::GetParam<string>("output_file").c_str(), arma::csv_ascii,
+      false, true);
 }

Modified: mlpack/trunk/src/mlpack/methods/nca/nca_softmax_error_function.h
===================================================================
--- mlpack/trunk/src/mlpack/methods/nca/nca_softmax_error_function.h	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/nca/nca_softmax_error_function.h	2011-10-29 04:26:38 UTC (rev 10069)
@@ -8,8 +8,7 @@
 #ifndef __MLPACK_METHODS_NCA_NCA_SOFTMAX_ERROR_FUNCTCLIN_H
 #define __MLPACK_METHODS_NCA_NCA_SOFTMAX_ERROR_FUNCTCLIN_H
 
-#include <armadillo>
-#include <map>
+#include <mlpack/core.h>
 
 namespace mlpack {
 namespace nca {

Modified: mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_main.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_main.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_main.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -13,8 +13,6 @@
 #include <fstream>
 #include <iostream>
 
-#include <armadillo>
-
 using namespace std;
 using namespace mlpack;
 using namespace mlpack::neighbor;
@@ -52,7 +50,8 @@
   arma::Mat<size_t> neighbors;
   arma::mat distances;
 
-  if (reference_data.load(reference_file.c_str()) == false)
+  if (!reference_data.load(reference_file.c_str(), arma::auto_detect, false,
+      true))
     Log::Fatal << "Reference file " << reference_file << "not found." << endl;
 
   Log::Info << "Loaded reference data from " << reference_file << endl;
@@ -78,7 +77,7 @@
     string query_file = CLI::GetParam<string>("query_file");
     arma::mat query_data;
 
-    if(query_data.load(query_file.c_str()) == false)
+    if(!query_data.load(query_file.c_str(), arma::auto_detect, false, true))
       Log::Fatal << "Query file " << query_file << " not found" << endl;
 
     Log::Info << "Query data loaded from " << query_file << endl;

Modified: mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_test.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_test.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_test.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -323,7 +323,8 @@
   arma::mat data_for_tree_;
 
   // Hard-coded filename: bad!
-  if (data_for_tree_.load("test_data_3_1000.csv") !=true )
+  if (!data_for_tree_.load("test_data_3_1000.csv", arma::auto_detect, false,
+      true))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
   // Set up matrices to work with.
@@ -353,7 +354,7 @@
   }
 }
 
-/***
+/**
  * Test the dual-tree furthest-neighbors method with the naive method.  This
  * uses only a reference dataset.
  *
@@ -364,7 +365,8 @@
 
   // Hard-coded filename: bad!
   // Code duplication: also bad!
-  if (data_for_tree_.quiet_load("test_data_3_1000.csv") !=true )
+  if (!data_for_tree_.load("test_data_3_1000.csv", arma::auto_detect, false,
+      true))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
   // Set up matrices to work with (may not be necessary with no ALIAS_MATRIX?).
@@ -392,7 +394,7 @@
   }
 }
 
-/***
+/**
  * Test the single-tree furthest-neighbors method with the naive method.  This
  * uses only a reference dataset.
  *
@@ -403,7 +405,8 @@
 
   // Hard-coded filename: bad!
   // Code duplication: also bad!
-  if (data_for_tree_.load("test_data_3_1000.csv") !=true )
+  if (!data_for_tree_.load("test_data_3_1000.csv", arma::auto_detect, false,
+      true))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
   arma::mat single_query(data_for_tree_);

Modified: mlpack/trunk/src/mlpack/methods/neighbor_search/allknn_main.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/neighbor_search/allknn_main.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/neighbor_search/allknn_main.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -13,8 +13,6 @@
 #include <fstream>
 #include <iostream>
 
-#include <armadillo>
-
 using namespace std;
 using namespace mlpack;
 using namespace mlpack::neighbor;
@@ -52,7 +50,8 @@
   arma::Mat<size_t> neighbors;
   arma::mat distances;
 
-  if (reference_data.load(reference_file.c_str()) == false)
+  if (!reference_data.load(reference_file.c_str(), arma::auto_detect, false,
+      true))
     Log::Fatal << "Reference file " << reference_file << " not found." << endl;
 
   Log::Info << "Loaded reference data from " << reference_file << endl;
@@ -78,7 +77,7 @@
     string query_file = CLI::GetParam<string>("query_file");
     arma::mat query_data;
 
-    if (query_data.load(query_file.c_str()) == false)
+    if (!query_data.load(query_file.c_str(), arma::auto_detect, false, true))
       Log::Fatal << "Query file " << query_file << " not found" << endl;
 
     Log::Info << "Query data loaded from " << query_file << endl;

Modified: mlpack/trunk/src/mlpack/methods/neighbor_search/allknn_test.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/neighbor_search/allknn_test.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/neighbor_search/allknn_test.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -313,7 +313,7 @@
   }
 }
 
-/***
+/**
  * Test the dual-tree nearest-neighbors method with the naive method.  This
  * uses both a query and reference dataset.
  *
@@ -323,7 +323,8 @@
   arma::mat data_for_tree_;
 
   // Hard-coded filename: bad!
-  if (data_for_tree_.load("test_data_3_1000.csv") !=true )
+  if (!data_for_tree_.load("test_data_3_1000.csv", arma::auto_detect, false,
+      true))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
   // Set up matrices to work with.
@@ -356,7 +357,7 @@
   }
 }
 
-/***
+/**
  * Test the dual-tree nearest-neighbors method with the naive method.  This uses
  * only a reference dataset.
  *
@@ -367,7 +368,8 @@
 
   // Hard-coded filename: bad!
   // Code duplication: also bad!
-  if (data_for_tree_.load("test_data_3_1000.csv") !=true )
+  if (!data_for_tree_.load("test_data_3_1000.csv", arma::auto_detect, false,
+      true))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
   // Set up matrices to work with (may not be necessary with no ALIAS_MATRIX?).
@@ -397,7 +399,7 @@
   }
 }
 
-/***
+/**
  * Test the single-tree nearest-neighbors method with the naive method.  This
  * uses only a reference dataset.
  *
@@ -408,7 +410,8 @@
 
   // Hard-coded filename: bad!
   // Code duplication: also bad!
-  if (data_for_tree_.load("test_data_3_1000.csv") !=true )
+  if (!data_for_tree_.load("test_data_3_1000.csv", arma::auto_detect, false,
+      true))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
   // Set up matrices to work with (may not be necessary with no ALIAS_MATRIX?).

Modified: mlpack/trunk/src/mlpack/methods/nnsvm/nnsvm_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/nnsvm/nnsvm_main.cpp	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/nnsvm/nnsvm_main.cpp	2011-10-29 04:26:38 UTC (rev 10069)
@@ -47,7 +47,7 @@
     std::string trainFile = CLI::GetParam<std::string>("nnsvm/train_data");
     // Load training data
     arma::mat dataSet;
-    if (dataSet.load(trainFile.c_str()) == false) // TODO:param_req
+    if (!dataSet.load(trainFile.c_str(), arma::auto_detect, false, true))
     {
       /* TODO: eventually, we need better exception handling */
       Log::Debug << "Could not open " << trainFile << " for reading" << std::endl;
@@ -74,7 +74,7 @@
         /* Load testing data */
         std::string testFile = CLI::GetParam<std::string>("nnsvm/test_data");
         arma::mat testset;
-        if (testset.load(testFile.c_str()) == false)// TODO:param_req
+        if (!testset.load(testFile.c_str(), arma::auto_detect, false, true))
         {
           /* TODO: eventually, we need better exception handling */
           Log::Debug << "Could not open " << testFile << " for reading" <<

Modified: mlpack/trunk/src/mlpack/methods/regression/ridge_main.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/regression/ridge_main.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/regression/ridge_main.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -69,12 +69,14 @@
   std::string predictions_file = CLI::GetParam<std::string>("ridge/predictions");
 
   arma::mat predictors;
-  if (predictors.load(predictors_file.c_str()) == false) {
+  if (predictors.load(predictors_file.c_str(), arma::auto_detect, false, true)
+      == false) {
     Log::Fatal << "Unable to open file " << predictors_file << std::endl;
   }
 
   arma::mat predictions;
-  if (predictions.load(predictions_file.c_str()) == false) {
+  if (predictions.load(predictions_file.c_str(), arma::auto_detect, false, true)
+      == false) {
     Log::Fatal << "Unable to open file " << predictions_file << std::endl;
   }
 
@@ -83,15 +85,14 @@
 
 
   if(mode == "regress") {
-
     engine = RidgeRegression(predictors, predictions,
-		CLI::GetParam<std::string>("ridge/inversion_method") == "normalsvd");
+        CLI::GetParam<std::string>("ridge/inversion_method") == "normalsvd");
     engine.QRRegress(lambda_min);
   }
   else if(mode == "cvregress") {
      Log::Info << "Crossvalidating for the optimal lambda in ["
-	<<  lambda_min << " " << lambda_max << " ] "
-     	<< "by trying " << num_lambdas_to_cv << " values..." << std::endl;
+        <<  lambda_min << " " << lambda_max << " ] "
+        << "by trying " << num_lambdas_to_cv << " values..." << std::endl;
 
     engine = RidgeRegression(predictors, predictions);
     engine.CrossValidatedRegression(lambda_min, lambda_max, num_lambdas_to_cv);
@@ -106,10 +107,14 @@
       CLI::GetParam<std::string>("ridge/predictor_indices");
     std::string prune_predictor_indices_file =
       CLI::GetParam<std::string>("ridge/prune_predictor_indices");
-    if (predictor_indices_intermediate.load(predictor_indices_file.c_str()) == false) {
-      Log::Fatal << "Unable to open file " << prune_predictor_indices_file << std::endl;
+    if (predictor_indices_intermediate.load(predictor_indices_file.c_str(),
+        arma::auto_detect, false, true) == false) {
+      Log::Fatal << "Unable to open file " << prune_predictor_indices_file
+          << std::endl;
     }
-    if (prune_predictor_indices_intermediate.load(prune_predictor_indices_file.c_str()) == false) {
+    if (prune_predictor_indices_intermediate.load(
+        prune_predictor_indices_file.c_str(), arma::auto_detect, false, true)
+        == false) {
       Log::Fatal << "Unable to open file " << prune_predictor_indices_file << std::endl;
     }
 
@@ -119,9 +124,9 @@
     { // Convert from double rowvec -> size_t colvec
       typedef arma::Col<size_t> size_t_vec;
       predictor_indices = arma::conv_to<size_t_vec>::
-                          from(predictor_indices_intermediate.row(0));
+          from(predictor_indices_intermediate.row(0));
       prune_predictor_indices = arma::conv_to<size_t_vec>::
-	                        from(prune_predictor_indices_intermediate.row(0));
+          from(prune_predictor_indices_intermediate.row(0));
     }
   }
 
@@ -133,8 +138,7 @@
   engine.factors(&factors);
   std::string factors_file = CLI::GetParam<std::string>("ridge/factors");
   Log::Info << "Saving factors..." << std::endl;
-  factors.save(factors_file.c_str());
-//  data::Save(factors_file.c_str(), factors);
+  factors.save(factors_file.c_str(), arma::csv_ascii, false, true);
 
   return 0;
 }

Modified: mlpack/trunk/src/mlpack/methods/svm/svm_main.cc
===================================================================
--- mlpack/trunk/src/mlpack/methods/svm/svm_main.cc	2011-10-29 04:18:01 UTC (rev 10068)
+++ mlpack/trunk/src/mlpack/methods/svm/svm_main.cc	2011-10-29 04:26:38 UTC (rev 10069)
@@ -94,7 +94,7 @@
     Log::Info << "Training SVM..." << std::endl;
 
     /* Load training data */
-    if (dataSet.load(trainFile.c_str()) == false)
+    if (!dataSet.load(trainFile.c_str(), arma::auto_detect, false, true))
       return 1;
 
     /* Begin SVM Training | Training and Testing */
@@ -108,7 +108,7 @@
         /* Load testing data */
         arma::mat dataSet;
         std::string testFile = CLI::GetParam<std::string>("svm/test_data");
-        if (dataSet.load(testFile.c_str()) == false)
+        if (!dataSet.load(testFile.c_str(), arma::auto_detect, false, true))
           return 1;
 
         svm.BatchPredict(learner_typeid, dataSet, "predicted_values");
@@ -123,7 +123,7 @@
         /* Load testing data */
         arma::mat dataSet;
         std::string testFile = CLI::GetParam<std::string>("svm/test_data");
-        if (dataSet.load(testFile.c_str()) == false)
+        if (!dataSet.load(testFile.c_str(), arma::auto_detect, false, true))
           return 1;
 
         svm.BatchPredict(learner_typeid, dataSet, "predicted_values"); // TODO:param_req




More information about the mlpack-svn mailing list