From 6a4ebb050aefb9bb2b9fca88ecff76de3df465ee Mon Sep 17 00:00:00 2001 From: jeffinsam Date: Sat, 27 Apr 2019 02:27:48 +0530 Subject: [PATCH 1/9] parameter change in perceptron.cpp --- .../methods/perceptron/perceptron_main.cpp | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/mlpack/methods/perceptron/perceptron_main.cpp b/src/mlpack/methods/perceptron/perceptron_main.cpp index 3a0ee47d4e..4efe8744cb 100644 --- a/src/mlpack/methods/perceptron/perceptron_main.cpp +++ b/src/mlpack/methods/perceptron/perceptron_main.cpp @@ -47,10 +47,18 @@ PROGRAM_INFO("Perceptron", " parameter), or both those things at once. In addition, this program " "allows classification on a test dataset (via the " + PRINT_PARAM_STRING("test") + " parameter) and the classification results " - "on the test set may be saved with the " + PRINT_PARAM_STRING("output") + + "on the test set may be saved with the " + PRINT_PARAM_STRING("predictions") + "output parameter. The perceptron model may be saved with the " + PRINT_PARAM_STRING("output_model") + " output parameter." "\n\n" + "Note : The following parameters are deprecated and " + "will be removed in mlpack 4: " + PRINT_PARAM_STRING("output") + + ", " + PRINT_PARAM_STRING("output_probabilities") + + "\nUse " + PRINT_PARAM_STRING("predictions") + " instead of " + + PRINT_PARAM_STRING("output") + "\nUse " + + PRINT_PARAM_STRING("probabilities") + " instead of " + + PRINT_PARAM_STRING("output_probabilities") + + "\n\n" "The training data given with the " + PRINT_PARAM_STRING("training") + " option may have class labels as its last dimension (so, if the training " "data is in CSV format, labels should be the last column). Alternately, " @@ -126,8 +134,14 @@ PARAM_MODEL_OUT(PerceptronModel, "output_model", "Output for trained perceptron" // Testing/classification parameters. PARAM_MATRIX_IN("test", "A matrix containing the test set.", "T"); +/* +* The PARAM_UROW_OUT("output") is depracated and +* can be removed in mlpack4.0.0. +*/ PARAM_UROW_OUT("output", "The matrix in which the predicted labels for the" " test set will be written.", "o"); +PARAM_UROW_OUT("predictions", "The matrix in which the predicted labels for the" + " test set will be written.", "P"); static void mlpackMain() { @@ -141,7 +155,9 @@ static void mlpackMain() // should issue a warning. RequireAtLeastOnePassed({ "output_model", "output" }, false, "no output will be saved"); + // "output" can be removed in mlpack 4 ReportIgnoredParam({{ "test", false }}, "output"); + ReportIgnoredParam({{ "test", false }}, "predictions"); // Check parameter validity. RequireParamValue("max_iterations", [](int x) { return x >= 0; }, @@ -297,6 +313,8 @@ static void mlpackMain() // Save the predicted labels. if (CLI::HasParam("output")) CLI::GetParam>("output") = std::move(results); + if (CLI::HasParam("predictions")) + CLI::GetParam>("predictions") = std::move(results); } // Lastly, save the output model. From 6862e7f3153d0cfb853069759119a120d7e36502 Mon Sep 17 00:00:00 2001 From: jeffinsam Date: Sat, 27 Apr 2019 23:52:21 +0530 Subject: [PATCH 2/9] removed unwanted parameters --- src/mlpack/methods/perceptron/perceptron_main.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/mlpack/methods/perceptron/perceptron_main.cpp b/src/mlpack/methods/perceptron/perceptron_main.cpp index 4efe8744cb..8341784048 100644 --- a/src/mlpack/methods/perceptron/perceptron_main.cpp +++ b/src/mlpack/methods/perceptron/perceptron_main.cpp @@ -47,17 +47,16 @@ PROGRAM_INFO("Perceptron", " parameter), or both those things at once. In addition, this program " "allows classification on a test dataset (via the " + PRINT_PARAM_STRING("test") + " parameter) and the classification results " - "on the test set may be saved with the " + PRINT_PARAM_STRING("predictions") + - "output parameter. The perceptron model may be saved with the " + + "on the test set may be saved with the " + + PRINT_PARAM_STRING("predictions") + + " output parameter. The perceptron model may be saved with the " + PRINT_PARAM_STRING("output_model") + " output parameter." "\n\n" - "Note : The following parameters are deprecated and " + "Note : The following parameter is deprecated and " "will be removed in mlpack 4: " + PRINT_PARAM_STRING("output") + - ", " + PRINT_PARAM_STRING("output_probabilities") + + "." + "\nUse " + PRINT_PARAM_STRING("predictions") + " instead of " + - PRINT_PARAM_STRING("output") + "\nUse " + - PRINT_PARAM_STRING("probabilities") + " instead of " + - PRINT_PARAM_STRING("output_probabilities") + + PRINT_PARAM_STRING("output")+'.' "\n\n" "The training data given with the " + PRINT_PARAM_STRING("training") + " option may have class labels as its last dimension (so, if the training " From 1fda341663348a7097d14daef1cab61fa43108ee Mon Sep 17 00:00:00 2001 From: jeffinsam Date: Sat, 27 Apr 2019 23:54:53 +0530 Subject: [PATCH 3/9] removed a white space --- src/mlpack/methods/perceptron/perceptron_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mlpack/methods/perceptron/perceptron_main.cpp b/src/mlpack/methods/perceptron/perceptron_main.cpp index 8341784048..303dce3e3e 100644 --- a/src/mlpack/methods/perceptron/perceptron_main.cpp +++ b/src/mlpack/methods/perceptron/perceptron_main.cpp @@ -154,7 +154,7 @@ static void mlpackMain() // should issue a warning. RequireAtLeastOnePassed({ "output_model", "output" }, false, "no output will be saved"); - // "output" can be removed in mlpack 4 + // "output" can be removed in mlpack 4 ReportIgnoredParam({{ "test", false }}, "output"); ReportIgnoredParam({{ "test", false }}, "predictions"); From c46f4c892af5d1a5bf4c7a53ae16bfea6b7fbf72 Mon Sep 17 00:00:00 2001 From: jeffinsam Date: Sun, 28 Apr 2019 01:24:02 +0530 Subject: [PATCH 4/9] added + and also changed paremeters in adaboost --- src/mlpack/methods/adaboost/adaboost_main.cpp | 25 ++++++++++++++++--- .../methods/perceptron/perceptron_main.cpp | 4 +-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/mlpack/methods/adaboost/adaboost_main.cpp b/src/mlpack/methods/adaboost/adaboost_main.cpp index ced3d3c1f2..96285bb6f5 100644 --- a/src/mlpack/methods/adaboost/adaboost_main.cpp +++ b/src/mlpack/methods/adaboost/adaboost_main.cpp @@ -77,10 +77,16 @@ PROGRAM_INFO("AdaBoost", "predictions for a given test dataset. A test dataset may be specified " "with the " + PRINT_PARAM_STRING("test") + " parameter. The predicted " "classes for each point in the test dataset are output to the " + - PRINT_PARAM_STRING("output") + " output parameter. The AdaBoost model " - "itself is output to the " + PRINT_PARAM_STRING("output_model") + + PRINT_PARAM_STRING("predictions") + " output parameter. The AdaBoost " + "model itself is output to the " + PRINT_PARAM_STRING("output_model") + " output parameter." "\n\n" + "Note : The following parameter is deprecated and " + "will be removed in mlpack 4: " + PRINT_PARAM_STRING("output") + + "." + + "\nUse " + PRINT_PARAM_STRING("predictions") + " instead of " + + PRINT_PARAM_STRING("output") + '.' + + "\n\n" "For example, to run AdaBoost on an input dataset " + PRINT_DATASET("data") + " with perceptrons as the weak learner type, " "storing the trained model in " + PRINT_MODEL("model") + ", one could " @@ -111,7 +117,12 @@ PARAM_UROW_IN("labels", "Labels for the training set.", "l"); // Classification options. PARAM_MATRIX_IN("test", "Test dataset.", "T"); +/* +* The PARAM_UROW_OUT("output") is depracated and +* can be removed in mlpack4.0.0. +*/ PARAM_UROW_OUT("output", "Predicted labels for the test set.", "o"); +PARAM_UROW_OUT("predictions", "Predicted labels for the test set.", "P"); // Training options. PARAM_INT_IN("iterations", "The maximum number of boosting iterations to be run" @@ -155,10 +166,12 @@ static void mlpackMain() if (CLI::HasParam("input_model")) RequireAtLeastOnePassed({ "test" }, false, "no task will be performed"); - RequireAtLeastOnePassed({ "output_model", "output" }, false, + RequireAtLeastOnePassed({ "output_model", "output", "predictions" }, false, "no results will be saved"); + // "output" can be removed in mlpack 4 ReportIgnoredParam({{ "test", false }}, "output"); + ReportIgnoredParam({{ "test", false }}, "predictions"); AdaBoostModel* m; if (CLI::HasParam("training")) @@ -230,7 +243,11 @@ static void mlpackMain() Row results; data::RevertLabels(predictedLabels, m->Mappings(), results); - CLI::GetParam>("output") = std::move(results); + // Save the predicted labels. + if (CLI::HasParam("output")) + CLI::GetParam>("output") = std::move(results); + if (CLI::HasParam("predictions")) + CLI::GetParam>("predictions") = std::move(results); } CLI::GetParam("output_model") = m; diff --git a/src/mlpack/methods/perceptron/perceptron_main.cpp b/src/mlpack/methods/perceptron/perceptron_main.cpp index 303dce3e3e..8cbeef43ff 100644 --- a/src/mlpack/methods/perceptron/perceptron_main.cpp +++ b/src/mlpack/methods/perceptron/perceptron_main.cpp @@ -56,7 +56,7 @@ PROGRAM_INFO("Perceptron", "will be removed in mlpack 4: " + PRINT_PARAM_STRING("output") + "." + "\nUse " + PRINT_PARAM_STRING("predictions") + " instead of " + - PRINT_PARAM_STRING("output")+'.' + PRINT_PARAM_STRING("output") + '.' + "\n\n" "The training data given with the " + PRINT_PARAM_STRING("training") + " option may have class labels as its last dimension (so, if the training " @@ -152,7 +152,7 @@ static void mlpackMain() // If the user isn't going to save the output model or any predictions, we // should issue a warning. - RequireAtLeastOnePassed({ "output_model", "output" }, false, + RequireAtLeastOnePassed({ "output_model", "output", "predictions" }, false, "no output will be saved"); // "output" can be removed in mlpack 4 ReportIgnoredParam({{ "test", false }}, "output"); From 4d987305b66fc96d53d4679449ef39157cfd2262 Mon Sep 17 00:00:00 2001 From: jeffinsam Date: Thu, 9 May 2019 23:38:54 +0530 Subject: [PATCH 5/9] style changes --- src/mlpack/methods/adaboost/adaboost_main.cpp | 8 +++----- src/mlpack/methods/perceptron/perceptron_main.cpp | 10 ++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/mlpack/methods/adaboost/adaboost_main.cpp b/src/mlpack/methods/adaboost/adaboost_main.cpp index 96285bb6f5..d72d870caa 100644 --- a/src/mlpack/methods/adaboost/adaboost_main.cpp +++ b/src/mlpack/methods/adaboost/adaboost_main.cpp @@ -118,8 +118,7 @@ PARAM_UROW_IN("labels", "Labels for the training set.", "l"); // Classification options. PARAM_MATRIX_IN("test", "Test dataset.", "T"); /* -* The PARAM_UROW_OUT("output") is depracated and -* can be removed in mlpack4.0.0. +* The PARAM_UROW_OUT("output") is deprecated and can be removed in mlpack4.0.0. */ PARAM_UROW_OUT("output", "Predicted labels for the test set.", "o"); PARAM_UROW_OUT("predictions", "Predicted labels for the test set.", "P"); @@ -169,8 +168,7 @@ static void mlpackMain() RequireAtLeastOnePassed({ "output_model", "output", "predictions" }, false, "no results will be saved"); - // "output" can be removed in mlpack 4 - ReportIgnoredParam({{ "test", false }}, "output"); + // "output" can be removed in mlpack 4. ReportIgnoredParam({{ "test", false }}, "predictions"); AdaBoostModel* m; @@ -245,7 +243,7 @@ static void mlpackMain() // Save the predicted labels. if (CLI::HasParam("output")) - CLI::GetParam>("output") = std::move(results); + CLI::GetParam>("output") = results; if (CLI::HasParam("predictions")) CLI::GetParam>("predictions") = std::move(results); } diff --git a/src/mlpack/methods/perceptron/perceptron_main.cpp b/src/mlpack/methods/perceptron/perceptron_main.cpp index 8cbeef43ff..2ff783669e 100644 --- a/src/mlpack/methods/perceptron/perceptron_main.cpp +++ b/src/mlpack/methods/perceptron/perceptron_main.cpp @@ -52,7 +52,7 @@ PROGRAM_INFO("Perceptron", " output parameter. The perceptron model may be saved with the " + PRINT_PARAM_STRING("output_model") + " output parameter." "\n\n" - "Note : The following parameter is deprecated and " + "Note: The following parameter is deprecated and " "will be removed in mlpack 4: " + PRINT_PARAM_STRING("output") + "." + "\nUse " + PRINT_PARAM_STRING("predictions") + " instead of " + @@ -134,8 +134,7 @@ PARAM_MODEL_OUT(PerceptronModel, "output_model", "Output for trained perceptron" // Testing/classification parameters. PARAM_MATRIX_IN("test", "A matrix containing the test set.", "T"); /* -* The PARAM_UROW_OUT("output") is depracated and -* can be removed in mlpack4.0.0. +* The PARAM_UROW_OUT("output") is deprecated and can be removed in mlpack4.0.0. */ PARAM_UROW_OUT("output", "The matrix in which the predicted labels for the" " test set will be written.", "o"); @@ -154,8 +153,7 @@ static void mlpackMain() // should issue a warning. RequireAtLeastOnePassed({ "output_model", "output", "predictions" }, false, "no output will be saved"); - // "output" can be removed in mlpack 4 - ReportIgnoredParam({{ "test", false }}, "output"); + // "output" can be removed in mlpack 4. ReportIgnoredParam({{ "test", false }}, "predictions"); // Check parameter validity. @@ -311,7 +309,7 @@ static void mlpackMain() // Save the predicted labels. if (CLI::HasParam("output")) - CLI::GetParam>("output") = std::move(results); + CLI::GetParam>("output") = results; if (CLI::HasParam("predictions")) CLI::GetParam>("predictions") = std::move(results); } From 308deb4bb96bb81cfa031fb82f884c3d4406fe5e Mon Sep 17 00:00:00 2001 From: jeffinsam Date: Thu, 9 May 2019 23:57:01 +0530 Subject: [PATCH 6/9] update history --- HISTORY.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index c2899db049..566dca2c95 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,14 @@ -### mlpack 3.1.0 +### mlpack 3.1.1 ###### ????-??-?? + * `output` option changed to `predictions` for adaboost and perceptron + binding.Old options are now deprecated and will be preserved until mlpack + 4.0.0 (#1882). + * Concatenated ReLU layer (#1843). + + * Accelerate NormalizeLabels function using hashing instead of linear search + (see `src/mlpack/core/data/normalize_labels_impl.hpp`)(#1780). + ### mlpack 3.1.0 ###### 2019-04-25 * Add DiagonalGaussianDistribution and DiagonalGMM classes to speed up the From d4dec4b0873cdb3b2d4eede00c44ee5179f881a1 Mon Sep 17 00:00:00 2001 From: jeffinsam Date: Fri, 10 May 2019 08:11:13 +0530 Subject: [PATCH 7/9] adapting style changes --- src/mlpack/methods/adaboost/adaboost_main.cpp | 7 ++++--- src/mlpack/methods/perceptron/perceptron_main.cpp | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mlpack/methods/adaboost/adaboost_main.cpp b/src/mlpack/methods/adaboost/adaboost_main.cpp index d72d870caa..2e54ac4f23 100644 --- a/src/mlpack/methods/adaboost/adaboost_main.cpp +++ b/src/mlpack/methods/adaboost/adaboost_main.cpp @@ -82,7 +82,7 @@ PROGRAM_INFO("AdaBoost", " output parameter." "\n\n" "Note : The following parameter is deprecated and " - "will be removed in mlpack 4: " + PRINT_PARAM_STRING("output") + + "will be removed in mlpack 4.0.0: " + PRINT_PARAM_STRING("output") + "." + "\nUse " + PRINT_PARAM_STRING("predictions") + " instead of " + PRINT_PARAM_STRING("output") + '.' + @@ -118,7 +118,8 @@ PARAM_UROW_IN("labels", "Labels for the training set.", "l"); // Classification options. PARAM_MATRIX_IN("test", "Test dataset.", "T"); /* -* The PARAM_UROW_OUT("output") is deprecated and can be removed in mlpack4.0.0. +* The PARAM_UROW_OUT("output") is deprecated and will be removed in +* mlpack 4.0.0. */ PARAM_UROW_OUT("output", "Predicted labels for the test set.", "o"); PARAM_UROW_OUT("predictions", "Predicted labels for the test set.", "P"); @@ -168,7 +169,7 @@ static void mlpackMain() RequireAtLeastOnePassed({ "output_model", "output", "predictions" }, false, "no results will be saved"); - // "output" can be removed in mlpack 4. + // "output" can be removed in mlpack 4.0.0. ReportIgnoredParam({{ "test", false }}, "predictions"); AdaBoostModel* m; diff --git a/src/mlpack/methods/perceptron/perceptron_main.cpp b/src/mlpack/methods/perceptron/perceptron_main.cpp index 2ff783669e..fd6c18221d 100644 --- a/src/mlpack/methods/perceptron/perceptron_main.cpp +++ b/src/mlpack/methods/perceptron/perceptron_main.cpp @@ -53,7 +53,7 @@ PROGRAM_INFO("Perceptron", PRINT_PARAM_STRING("output_model") + " output parameter." "\n\n" "Note: The following parameter is deprecated and " - "will be removed in mlpack 4: " + PRINT_PARAM_STRING("output") + + "will be removed in mlpack 4.0.0: " + PRINT_PARAM_STRING("output") + "." + "\nUse " + PRINT_PARAM_STRING("predictions") + " instead of " + PRINT_PARAM_STRING("output") + '.' + @@ -134,7 +134,8 @@ PARAM_MODEL_OUT(PerceptronModel, "output_model", "Output for trained perceptron" // Testing/classification parameters. PARAM_MATRIX_IN("test", "A matrix containing the test set.", "T"); /* -* The PARAM_UROW_OUT("output") is deprecated and can be removed in mlpack4.0.0. +* The PARAM_UROW_OUT("output") is deprecated and will be removed in +* mlpack 4.0.0. */ PARAM_UROW_OUT("output", "The matrix in which the predicted labels for the" " test set will be written.", "o"); From 06efecb68b675149b4d3c7d7a0cbe556d6081897 Mon Sep 17 00:00:00 2001 From: jeffinsam Date: Sat, 11 May 2019 08:12:02 +0530 Subject: [PATCH 8/9] Adding test and documentation fixup --- HISTORY.md | 2 +- src/mlpack/methods/adaboost/adaboost_main.cpp | 2 +- .../methods/perceptron/perceptron_main.cpp | 4 +-- src/mlpack/tests/main_tests/adaboost_test.cpp | 22 +++++++++++++ .../tests/main_tests/perceptron_test.cpp | 33 +++++++++++++++++++ 5 files changed, 59 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 566dca2c95..15d82698ef 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,7 +1,7 @@ ### mlpack 3.1.1 ###### ????-??-?? * `output` option changed to `predictions` for adaboost and perceptron - binding.Old options are now deprecated and will be preserved until mlpack + binding. Old options are now deprecated and will be preserved until mlpack 4.0.0 (#1882). * Concatenated ReLU layer (#1843). diff --git a/src/mlpack/methods/adaboost/adaboost_main.cpp b/src/mlpack/methods/adaboost/adaboost_main.cpp index 2e54ac4f23..b26be72c58 100644 --- a/src/mlpack/methods/adaboost/adaboost_main.cpp +++ b/src/mlpack/methods/adaboost/adaboost_main.cpp @@ -101,7 +101,7 @@ PROGRAM_INFO("AdaBoost", PRINT_DATASET("predictions") + " with the following command: " "\n\n" + PRINT_CALL("adaboost", "input_model", "model", "test", "test_data", - "output", "predictions"), + "predictions", "predictions"), // See also... SEE_ALSO("AdaBoost on Wikipedia", "https://en.wikipedia.org/wiki/AdaBoost"), SEE_ALSO("Improved boosting algorithms using confidence-rated predictions " diff --git a/src/mlpack/methods/perceptron/perceptron_main.cpp b/src/mlpack/methods/perceptron/perceptron_main.cpp index fd6c18221d..e8895e12c3 100644 --- a/src/mlpack/methods/perceptron/perceptron_main.cpp +++ b/src/mlpack/methods/perceptron/perceptron_main.cpp @@ -78,7 +78,7 @@ PROGRAM_INFO("Perceptron", "saving the predicted classes to " + PRINT_DATASET("predictions") + "." "\n\n" + PRINT_CALL("perceptron", "input_model", "perceptron_model", "test", - "test_data", "output", "predictions") + + "test_data", "predictions", "predictions") + "\n\n" "Note that all of the options may be specified at once: predictions may be " "calculated right after training a model, and model training can occur even" @@ -154,7 +154,7 @@ static void mlpackMain() // should issue a warning. RequireAtLeastOnePassed({ "output_model", "output", "predictions" }, false, "no output will be saved"); - // "output" can be removed in mlpack 4. + // "output" can be removed in mlpack 4.0.0. ReportIgnoredParam({{ "test", false }}, "predictions"); // Check parameter validity. diff --git a/src/mlpack/tests/main_tests/adaboost_test.cpp b/src/mlpack/tests/main_tests/adaboost_test.cpp index 29f1c92455..2c9f091c9b 100644 --- a/src/mlpack/tests/main_tests/adaboost_test.cpp +++ b/src/mlpack/tests/main_tests/adaboost_test.cpp @@ -205,6 +205,28 @@ BOOST_AUTO_TEST_CASE(AdaBoostTrainingDataOrModelTest) BOOST_REQUIRE_THROW(mlpackMain(), std::runtime_error); Log::Fatal.ignoreInput = false; } +/** + * This test can be removed in mlpack 4.0.0. Testing + * the output and predictions outputs are the same. + */ +BOOST_AUTO_TEST_CASE(AdaBoostOutputPredictionsTest) +{ + arma::mat trainData; + if (!data::Load("vc2.csv", trainData)) + BOOST_FAIL("Unable to load train dataset vc2.csv!"); + + arma::Row labels; + if (!data::Load("vc2_labels.txt", labels)) + BOOST_FAIL("Unable to load label dataset vc2_labels.txt!"); + + SetInputParam("training", std::move(trainData)); + SetInputParam("labels", std::move(labels)); + + mlpackMain(); + + CheckMatrices(CLI::GetParam>("output"), + CLI::GetParam>("predictions")); +} /** * Weak learner should be either Decision Stump or Perceptron. diff --git a/src/mlpack/tests/main_tests/perceptron_test.cpp b/src/mlpack/tests/main_tests/perceptron_test.cpp index c096088bb0..aca7db888f 100644 --- a/src/mlpack/tests/main_tests/perceptron_test.cpp +++ b/src/mlpack/tests/main_tests/perceptron_test.cpp @@ -162,6 +162,39 @@ BOOST_AUTO_TEST_CASE(PerceptronLabelsLessDimensionTest) CheckMatrices(output, CLI::GetParam>("output")); } +/** + * This test can be removed in mlpack 4.0.0. Testing + * the output and predictions outputs are the same. + */ +BOOST_AUTO_TEST_CASE(PerceptronOutputPredictionsCheck) +{ + arma::mat trainX1; + arma::Row labelsX1; + + // Loading a train data set with 3 classes. + if (!data::Load("vc2.csv", trainX1)) + { + BOOST_FAIL("Could not load the train data (vc2.csv)"); + } + + // Loading the corresponding labels to the dataset. + if (!data::Load("vc2_labels.txt", labelsX1)) + { + BOOST_FAIL("Could not load the train data (vc2_labels.csv)"); + } + + SetInputParam("training", std::move(trainX1)); // Training data. + // Labels for the training data. + SetInputParam("labels", std::move(labelsX1)); + + // Training model using first training dataset. + mlpackMain(); + + // Check that the outputs are the same. + CheckMatrices(CLI::GetParam>("output"), + CLI::GetParam>("predictions")); +} + /** * Ensure that saved model can be used again. */ From 328dd57d699c91921afc568a3074ab0c98cdc316 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Sat, 11 May 2019 20:10:56 -0400 Subject: [PATCH 9/9] Minor style changes. --- src/mlpack/methods/adaboost/adaboost_main.cpp | 14 ++++++-------- src/mlpack/methods/perceptron/perceptron_main.cpp | 14 ++++++-------- src/mlpack/tests/main_tests/adaboost_test.cpp | 5 +++-- src/mlpack/tests/main_tests/perceptron_test.cpp | 4 ++-- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/mlpack/methods/adaboost/adaboost_main.cpp b/src/mlpack/methods/adaboost/adaboost_main.cpp index b26be72c58..1ace9dd5ec 100644 --- a/src/mlpack/methods/adaboost/adaboost_main.cpp +++ b/src/mlpack/methods/adaboost/adaboost_main.cpp @@ -81,10 +81,11 @@ PROGRAM_INFO("AdaBoost", "model itself is output to the " + PRINT_PARAM_STRING("output_model") + " output parameter." "\n\n" - "Note : The following parameter is deprecated and " + "Note: the following parameter is deprecated and " "will be removed in mlpack 4.0.0: " + PRINT_PARAM_STRING("output") + - "." + - "\nUse " + PRINT_PARAM_STRING("predictions") + " instead of " + + "." + "\n" + "Use " + PRINT_PARAM_STRING("predictions") + " instead of " + PRINT_PARAM_STRING("output") + '.' + "\n\n" "For example, to run AdaBoost on an input dataset " + @@ -117,10 +118,7 @@ PARAM_UROW_IN("labels", "Labels for the training set.", "l"); // Classification options. PARAM_MATRIX_IN("test", "Test dataset.", "T"); -/* -* The PARAM_UROW_OUT("output") is deprecated and will be removed in -* mlpack 4.0.0. -*/ +// PARAM_UROW_OUT("output") is deprecated and will be removed in mlpack 4.0.0. PARAM_UROW_OUT("output", "Predicted labels for the test set.", "o"); PARAM_UROW_OUT("predictions", "Predicted labels for the test set.", "P"); @@ -169,7 +167,7 @@ static void mlpackMain() RequireAtLeastOnePassed({ "output_model", "output", "predictions" }, false, "no results will be saved"); - // "output" can be removed in mlpack 4.0.0. + // "output" will be removed in mlpack 4.0.0. ReportIgnoredParam({{ "test", false }}, "predictions"); AdaBoostModel* m; diff --git a/src/mlpack/methods/perceptron/perceptron_main.cpp b/src/mlpack/methods/perceptron/perceptron_main.cpp index e8895e12c3..8d52ab0a98 100644 --- a/src/mlpack/methods/perceptron/perceptron_main.cpp +++ b/src/mlpack/methods/perceptron/perceptron_main.cpp @@ -52,10 +52,11 @@ PROGRAM_INFO("Perceptron", " output parameter. The perceptron model may be saved with the " + PRINT_PARAM_STRING("output_model") + " output parameter." "\n\n" - "Note: The following parameter is deprecated and " + "Note: the following parameter is deprecated and " "will be removed in mlpack 4.0.0: " + PRINT_PARAM_STRING("output") + - "." + - "\nUse " + PRINT_PARAM_STRING("predictions") + " instead of " + + "." + "\n" + "Use " + PRINT_PARAM_STRING("predictions") + " instead of " + PRINT_PARAM_STRING("output") + '.' + "\n\n" "The training data given with the " + PRINT_PARAM_STRING("training") + @@ -133,10 +134,7 @@ PARAM_MODEL_OUT(PerceptronModel, "output_model", "Output for trained perceptron" // Testing/classification parameters. PARAM_MATRIX_IN("test", "A matrix containing the test set.", "T"); -/* -* The PARAM_UROW_OUT("output") is deprecated and will be removed in -* mlpack 4.0.0. -*/ +// PARAM_UROW_OUT("output") is deprecated and will be removed in PARAM_UROW_OUT("output", "The matrix in which the predicted labels for the" " test set will be written.", "o"); PARAM_UROW_OUT("predictions", "The matrix in which the predicted labels for the" @@ -154,7 +152,7 @@ static void mlpackMain() // should issue a warning. RequireAtLeastOnePassed({ "output_model", "output", "predictions" }, false, "no output will be saved"); - // "output" can be removed in mlpack 4.0.0. + // "output" will be removed in mlpack 4.0.0. ReportIgnoredParam({{ "test", false }}, "predictions"); // Check parameter validity. diff --git a/src/mlpack/tests/main_tests/adaboost_test.cpp b/src/mlpack/tests/main_tests/adaboost_test.cpp index 2c9f091c9b..ef27998f0d 100644 --- a/src/mlpack/tests/main_tests/adaboost_test.cpp +++ b/src/mlpack/tests/main_tests/adaboost_test.cpp @@ -205,9 +205,10 @@ BOOST_AUTO_TEST_CASE(AdaBoostTrainingDataOrModelTest) BOOST_REQUIRE_THROW(mlpackMain(), std::runtime_error); Log::Fatal.ignoreInput = false; } + /** - * This test can be removed in mlpack 4.0.0. Testing - * the output and predictions outputs are the same. + * This test can be removed in mlpack 4.0.0. This tests that the output and + * predictions outputs are the same. */ BOOST_AUTO_TEST_CASE(AdaBoostOutputPredictionsTest) { diff --git a/src/mlpack/tests/main_tests/perceptron_test.cpp b/src/mlpack/tests/main_tests/perceptron_test.cpp index aca7db888f..1704abdd7b 100644 --- a/src/mlpack/tests/main_tests/perceptron_test.cpp +++ b/src/mlpack/tests/main_tests/perceptron_test.cpp @@ -163,8 +163,8 @@ BOOST_AUTO_TEST_CASE(PerceptronLabelsLessDimensionTest) } /** - * This test can be removed in mlpack 4.0.0. Testing - * the output and predictions outputs are the same. + * This test can be removed in mlpack 4.0.0. This tests that the output and + * predictions outputs are the same. */ BOOST_AUTO_TEST_CASE(PerceptronOutputPredictionsCheck) {