[mlpack] 189/324: Minor changes to the macros in the *main.cpp files.
Barak A. Pearlmutter
barak+git at cs.nuim.ie
Sun Aug 17 08:22:09 UTC 2014
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch svn-trunk
in repository mlpack.
commit 9b62228f6b3f70c681124dd328c1dbf4ad4db4ac
Author: saxena.udit <saxena.udit at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date: Wed Jul 16 15:12:44 2014 +0000
Minor changes to the macros in the *main.cpp files.
git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16830 9d5b8971-822b-0410-80eb-d18c1038ef23
---
.../methods/decision_stump/decision_stump_main.cpp | 6 +--
src/mlpack/methods/perceptron/perceptron_main.cpp | 54 ++++++++++++++++++----
2 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/src/mlpack/methods/decision_stump/decision_stump_main.cpp b/src/mlpack/methods/decision_stump/decision_stump_main.cpp
index fe92e33..f6d6053 100644
--- a/src/mlpack/methods/decision_stump/decision_stump_main.cpp
+++ b/src/mlpack/methods/decision_stump/decision_stump_main.cpp
@@ -16,9 +16,9 @@ PROGRAM_INFO("Decision Stump",
"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"
diff --git a/src/mlpack/methods/perceptron/perceptron_main.cpp b/src/mlpack/methods/perceptron/perceptron_main.cpp
index 03100d9..2ca8218 100644
--- a/src/mlpack/methods/perceptron/perceptron_main.cpp
+++ b/src/mlpack/methods/perceptron/perceptron_main.cpp
@@ -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 mlpack::perceptron;
using namespace std;
using namespace arma;
-PROGRAM_INFO("Perceptron","");
-
-//necessary parameters
-PARAM_STRING_REQ("train_file", "A file containing the training set.", "tr");
+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.", "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 @@ int main(int argc, char *argv[])
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;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list