[mlpack-git] [mlpack/mlpack] Allow input and output parameters to be specified with PARAM_* macros (#723)
Ryan Curtin
notifications at github.com
Fri Jul 15 11:52:33 EDT 2016
This is part one of the automatic bindings project. I've taken all of the macros like `PARAM_STRING` and refactored them into `PARAM_STRING_IN` and `PARAM_STRING_OUT`, to denote which are input parameters and which are output parameters. This information will be necessary when I am generating bindings to other languages.
I then had to go through all of the command-line programs and adapt the options. In some cases, I had to change the name of parameters, but I preserved the old versions for reverse-compatibility (so there is some code we will be able to remove for mlpack 3.0.0). Any input string parameters that are filenames must have names that end in `_file`.
Note that while there is, e.g., `PARAM_STRING_IN_REQ()` (a required input parameter), there is no `PARAM_STRING_OUT_REQ()` since I don't think it's reasonable to require that users handle their output. That means that some programs, like `mlpack_preprocess_split` and others, have been changed to issue warnings instead of fatal errors when output parameters are not specified.
When there is an output parameter that does not end in `_file`, its value will be printed to stdout at the termination of the program. Right now I think only `mlpack_hmm_loglik` uses a non-filename output parameter.
I've tested each of the command-line programs to ensure that they still function, and in some cases I've fixed a few bugs with them.
@keonkim: my work affects mlpack_preprocess_split and mlpack_preprocess_binarize more than trivially, so let me know if any of my changes are problematic.
@mentekid: when I merged `lsh_main.cpp` with multiprobe and recall computation support, the merge was imperfect. I think I fixed everything, but can you take a quick look and make sure everything still works properly?
@zoq: I could not get the `mlpack_rmva` program to run correctly ("`Target class out of range`"), but I couldn't get it to work before, either, so I don't know if my changes have broken anything.
The only reason all these checks are necessary is that we don't have a good infrastructure for testing command-line executables. But, this change here is the first in a long set of steps to getting that infrastructure built.
(The next part of the plan, not included in this PR, is to change `PARAM_STRING_IN("input_file", "...", "i");` to `PARAM_MATRIX_IN("input", "...", "i");` and then the input matrix will be available directly with `CLI::GetParam<arma::mat>("input");`, and the help dialog will automatically display an entry for `--input_file`, so that the changes are transparent to the user.)
You can view, comment on, or merge this pull request online at:
https://github.com/mlpack/mlpack/pull/723
-- Commit Summary --
* Refactor to support input and output parameters.
* Refactor programs to support input and output parameters.
* Merge branch 'master' into bindings
* Fix duplicate options.
* Don't print extra lines.
* Warn when the user does not specify a file to test but asks for output.
* Fix misspelled parameter name.
* Fix parameter name issues.
* Better warnings when --output_file is not specified.
* Correct warning for no output.
* There is no such thing as a required output option.
* Update to --output_predictions_file, but keep old version for reverse compatibility.
* Only print output parameters that are strings and end with "_file".
* Print any output options at the end of the run.
* Fix wrong conditional for printing warning.
* Add warning for kernel_pca when --output_file is not specified.
* Add reverse compatibility for some incorrectly-named parameters.
-- File Changes --
M src/mlpack/core/util/cli.cpp (126)
M src/mlpack/core/util/cli.hpp (351)
M src/mlpack/core/util/cli_impl.hpp (20)
M src/mlpack/core/util/option.hpp (8)
M src/mlpack/core/util/option_impl.hpp (11)
A src/mlpack/core/util/param.hpp (426)
M src/mlpack/methods/adaboost/adaboost_main.cpp (37)
M src/mlpack/methods/cf/cf_main.cpp (44)
M src/mlpack/methods/decision_stump/decision_stump_main.cpp (23)
M src/mlpack/methods/det/det_main.cpp (37)
M src/mlpack/methods/emst/emst_main.cpp (20)
M src/mlpack/methods/fastmks/fastmks_main.cpp (33)
M src/mlpack/methods/gmm/gmm_generate_main.cpp (13)
M src/mlpack/methods/gmm/gmm_probability_main.cpp (19)
M src/mlpack/methods/gmm/gmm_train_main.cpp (26)
M src/mlpack/methods/hmm/hmm_generate_main.cpp (23)
M src/mlpack/methods/hmm/hmm_loglik_main.cpp (8)
M src/mlpack/methods/hmm/hmm_train_main.cpp (21)
M src/mlpack/methods/hmm/hmm_viterbi_main.cpp (10)
M src/mlpack/methods/hoeffding_trees/hoeffding_tree_main.cpp (36)
M src/mlpack/methods/kernel_pca/kernel_pca_main.cpp (31)
M src/mlpack/methods/kmeans/kmeans_main.cpp (37)
M src/mlpack/methods/lars/lars_main.cpp (61)
M src/mlpack/methods/linear_regression/linear_regression_main.cpp (63)
M src/mlpack/methods/local_coordinate_coding/local_coordinate_coding_main.cpp (32)
M src/mlpack/methods/logistic_regression/logistic_regression_main.cpp (48)
M src/mlpack/methods/lsh/lsh_main.cpp (49)
M src/mlpack/methods/mean_shift/mean_shift_main.cpp (80)
M src/mlpack/methods/mvu/mvu_main.cpp (8)
M src/mlpack/methods/naive_bayes/nbc_main.cpp (17)
M src/mlpack/methods/nca/nca_main.cpp (49)
M src/mlpack/methods/neighbor_search/kfn_main.cpp (42)
M src/mlpack/methods/neighbor_search/knn_main.cpp (29)
M src/mlpack/methods/nmf/nmf_main.cpp (36)
M src/mlpack/methods/pca/pca_main.cpp (27)
M src/mlpack/methods/perceptron/perceptron_main.cpp (34)
M src/mlpack/methods/preprocess/preprocess_binarize_main.cpp (18)
M src/mlpack/methods/preprocess/preprocess_split_main.cpp (64)
M src/mlpack/methods/radical/radical_main.cpp (65)
M src/mlpack/methods/range_search/range_search_main.cpp (27)
M src/mlpack/methods/rann/krann_main.cpp (31)
M src/mlpack/methods/rmva/rmva_main.cpp (37)
M src/mlpack/methods/softmax_regression/softmax_regression_main.cpp (35)
M src/mlpack/methods/sparse_coding/sparse_coding_main.cpp (56)
M src/mlpack/tests/cli_test.cpp (2)
-- Patch Links --
https://github.com/mlpack/mlpack/pull/723.patch
https://github.com/mlpack/mlpack/pull/723.diff
---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/723
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160715/8593c3f0/attachment.html>
More information about the mlpack-git
mailing list