[mlpack-svn] r16830 - in mlpack/trunk/src/mlpack/methods: decision_stump perceptron

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Jul 16 11:12:44 EDT 2014


Author: saxena.udit
Date: Wed Jul 16 11:12:44 2014
New Revision: 16830

Log:
Minor changes to the macros in the *main.cpp files.

Modified:
   mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump_main.cpp
   mlpack/trunk/src/mlpack/methods/perceptron/perceptron_main.cpp

Modified: mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump_main.cpp	Wed Jul 16 11:12:44 2014
@@ -16,9 +16,9 @@
     "This program implements a decision stump, which is a single-level decision"
     " tree.  The decision stump will split on one dimension of the input data, "
     "and will split into multiple buckets.  The dimension and bins are selected"
-    " by minimizing the entropy of the split.  Optionally, the minimum number "
-    "of training points in each bin can be specified with the --bin_size (-b) "
-    "parameter.\n"
+    " by maximizing the information gain of the split.  Optionally, the minimum"
+    " number of training points in each bin can be specified with the "
+    "--bin_size (-b) parameter.\n"
     "\n"
     "The decision stump is parameterized by a splitting dimension and a vector "
     "of values that denote the splitting values of each bin.\n"

Modified: mlpack/trunk/src/mlpack/methods/perceptron/perceptron_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/perceptron/perceptron_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/perceptron/perceptron_main.cpp	Wed Jul 16 11:12:44 2014
@@ -2,7 +2,7 @@
  * @file: perceptron_main.cpp
  * @author: Udit Saxena
  *
- *
+ * Main executable for the Perceptron.
  */
 
 #include <mlpack/core.hpp>
@@ -13,15 +13,36 @@
 using namespace std;
 using namespace arma;
 
-PROGRAM_INFO("Perceptron","");
+PROGRAM_INFO("Perceptron",
+    "This program implements a perceptron, which is a single level "
+    "Neural Network. The perceptron makes its predictions based on "
+    "a linear predictor function combining a set of weights with the feature "
+    "vector.\n"
+    "The perceptron learning rule is able to converge, given enough iterations "
+    "using the --iterations (-i) parameter, if the data supplied is "
+    "linearly separable. "
+    "\n"
+    "The Perceptron is parameterized by a matrix of weight vectors which "
+    "denotes the numerical weights of the Neural Network."
+    "\n"
+    "This program allows training of a perceptron, and then application of "
+    "the learned perceptron to a test dataset.  To train a perceptron, "
+    "a training dataset must be passed to --train_file (-t).  Labels can either "
+    "be present as the last dimension of the training dataset, or given "
+    "explicitly with the --labels_file (-l) parameter."
+    "\n"
+    "A test file is given through the --test_file (-T) parameter.  The "
+    "predicted labels for the test set will be stored in the file specified by "
+    "the --output_file (-o) parameter."
+    );
 
-//necessary parameters
-PARAM_STRING_REQ("train_file", "A file containing the training set.", "tr");
+// Necessary parameters
+PARAM_STRING_REQ("train_file", "A file containing the training set.", "t");
 PARAM_STRING_REQ("labels_file", "A file containing labels for the training set.",
   "l");
-PARAM_STRING_REQ("test_file", "A file containing the test set.", "te");
+PARAM_STRING_REQ("test_file", "A file containing the test set.", "T");
 
-//optional parameters.
+// Optional parameters.
 PARAM_STRING("output", "The file in which the predicted labels for the test set"
     " will be written.", "o", "output.csv");
 PARAM_INT("iterations","The maximum number of iterations the perceptron is "
@@ -38,8 +59,25 @@
   const string labelsFilename = CLI::GetParam<string>("labels_file");
   // Load labels.
   mat labelsIn;
-  data::Load(labelsFilename, labelsIn, true);
 
+  if (CLI::HasParam("labels_file"))
+  {
+    const string labelsFilename = CLI::GetParam<string>("labels_file");
+    // Load labels.
+    data::Load(labelsFilename, labelsIn, true);
+
+    // Do the labels need to be transposed?
+    if (labelsIn.n_rows == 1)
+      labelsIn = labelsIn.t();
+  }
+  else
+  {
+    // Extract the labels as the last
+    Log::Info << "Using the last dimension of training set as labels." << endl;
+
+    labelsIn = trainingData.row(trainingData.n_rows - 1).t();
+    trainingData.shed_row(trainingData.n_rows - 1);
+  }
   // helpers for normalizing the labels
   Col<size_t> labels;
   vec mappings;



More information about the mlpack-svn mailing list