[mlpack-git] master, mlpack-1.0.x: Assume the response to be the last column of the input file, as pointed out in the description. (6624a42)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:49:49 EST 2015


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

On branches: master,mlpack-1.0.x
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit 6624a4211231fc0e571593b958b068d16fa69ea8
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date:   Thu Jun 26 14:25:46 2014 +0000

    Assume the response to be the last column of the input file, as pointed out in the description.


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

6624a4211231fc0e571593b958b068d16fa69ea8
 .../logistic_regression/logistic_regression_main.cpp       | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/mlpack/methods/logistic_regression/logistic_regression_main.cpp b/src/mlpack/methods/logistic_regression/logistic_regression_main.cpp
index 6e204e1..6a053ac 100644
--- a/src/mlpack/methods/logistic_regression/logistic_regression_main.cpp
+++ b/src/mlpack/methods/logistic_regression/logistic_regression_main.cpp
@@ -104,11 +104,6 @@ int main(int argc, char** argv)
     Log::Fatal << "One of --model_file or --input_file must be specified."
         << endl;
 
-  // If inputFile is specified, it must also have some responses with it.
-  if (!inputFile.empty() && inputResponsesFile.empty())
-    Log::Fatal << "If --input_file is specified, then --input_responses must "
-        << "also be specified." << endl;
-
   // If they want predictions, they should supply a file to save them to.  This
   // is only a warning because the program can still work.
   if (!testFile.empty() && outputPredictionsFile.empty())
@@ -154,6 +149,8 @@ int main(int argc, char** argv)
   // Load matrices.
   if (!inputFile.empty())
     data::Load(inputFile, regressors, true);
+
+  // Check if the responses are in a separate file.
   if (!inputResponsesFile.empty())
   {
     data::Load(inputResponsesFile, responses, true);
@@ -163,6 +160,13 @@ int main(int argc, char** argv)
       Log::Fatal << "The responses (--input_responses) must have the same "
           << "number of points as the input dataset (--input_file)." << endl;
   }
+  else
+  {
+    // The initial predictors for y, Nx1.
+    responses = trans(regressors.row(regressors.n_rows - 1));
+    regressors.shed_row(regressors.n_rows - 1);
+  }
+
   if (!testFile.empty())
     data::Load(testFile, testSet, true);
   if (!modelFile.empty())



More information about the mlpack-git mailing list