Commit 79656869 authored by Davis King's avatar Davis King

Simplified CLI code

parent 25bf3c51
......@@ -12,8 +12,8 @@
#include "dlib/matrix.h"
typedef dlib::cmd_line_parser<char>::check_1a_c clp;
using dlib::command_line_parser;
typedef std::map<unsigned long, double> sparse_sample_type;
typedef dlib::matrix<sparse_sample_type::value_type::second_type,0,1> dense_sample_type;
......
......@@ -16,6 +16,7 @@
#include <vector>
#include "dlib/cmd_line_parser.h"
#include "dlib/data_io.h"
#include "dlib/svm.h"
......@@ -24,7 +25,7 @@ using namespace dlib;
// ----------------------------------------------------------------------------------------
static void
parse_args (clp& parser, int argc, char* argv[])
parse_args (command_line_parser& parser, int argc, char* argv[])
{
try {
// Algorithm-independent options
......@@ -107,18 +108,16 @@ parse_args (clp& parser, int argc, char* argv[])
int
main (int argc, char* argv[])
{
clp parser;
command_line_parser parser;
parse_args(parser, argc, argv);
const clp::option_type& option_alg = parser.option("a");
const clp::option_type& option_in = parser.option("in");
std::vector<sparse_sample_type> sparse_samples;
std::vector<double> labels;
load_libsvm_formatted_data (
option_in.argument(),
parser.option("in").argument(),
sparse_samples,
labels
);
......@@ -155,6 +154,7 @@ main (int argc, char* argv[])
// Randomize the order of the samples, labels
randomize_samples (dense_samples, labels);
const command_line_parser::option_type& option_alg = parser.option("a");
if (!option_alg) {
// Do KRR if user didn't specify an algorithm
std::cout << "No algorithm specified, default to KRR\n";
......
......@@ -21,7 +21,7 @@ exp10_ (double m)
void
option_range::set_option (
clp& parser,
command_line_parser& parser,
std::string const& option,
float default_val
)
......
......@@ -32,7 +32,7 @@ public:
max_value = 100;
incr = 10;
}
void set_option (clp& parser, std::string const& option,
void set_option (command_line_parser& parser, std::string const& option,
float default_val);
float get_min_value ();
float get_max_value ();
......
......@@ -20,7 +20,7 @@ using namespace std;
static const char*
get_kernel (
clp& parser
command_line_parser& parser
)
{
const char* kernel = "rbk";
......@@ -34,7 +34,7 @@ get_kernel (
static void
get_rbk_gamma (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
option_range& range
) {
......@@ -47,7 +47,7 @@ get_rbk_gamma (
static void
get_krls_tolerance (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
option_range& range
)
......@@ -60,7 +60,7 @@ get_krls_tolerance (
static double
get_mlp_hidden_units (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples
)
{
......@@ -75,7 +75,7 @@ get_mlp_hidden_units (
static double
get_mlp_num_iterations (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples
)
{
......@@ -90,7 +90,7 @@ get_mlp_num_iterations (
static void
get_svr_c (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
option_range& range
)
......@@ -103,7 +103,7 @@ get_svr_c (
static double
get_svr_epsilon_insensitivity (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples
)
{
......@@ -125,7 +125,7 @@ get_svr_epsilon_insensitivity (
void
krls_test (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
std::vector<double>& labels
)
......@@ -176,7 +176,7 @@ krls_test (
static void
krr_rbk_test (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
std::vector<double>& labels
)
......@@ -229,7 +229,7 @@ krr_rbk_test (
static void
krr_lin_test (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
std::vector<double>& labels
)
......@@ -250,7 +250,7 @@ krr_lin_test (
void
krr_test (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
std::vector<double>& labels
)
......@@ -271,7 +271,7 @@ krr_test (
void
mlp_test (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
std::vector<double>& labels
)
......@@ -321,7 +321,7 @@ mlp_test (
void
svr_test (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
std::vector<double>& labels
)
......
......@@ -12,28 +12,28 @@
void
krr_test (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
std::vector<double>& labels
);
void
krls_test (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
std::vector<double>& labels
);
void
mlp_test (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
std::vector<double>& labels
);
void
svr_test (
clp& parser,
command_line_parser& parser,
std::vector<dense_sample_type>& dense_samples,
std::vector<double>& labels
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment