16 static struct gk_option slim_options[] = {
45 static char helpstr[][512] = {
48 " slim_learn [options]",
50 " -train_file=string",
51 " Specifies the input file which contains the training data. This file should be",
55 " Specifies the input file which contains the testing data. This file should be",
58 " -model_file=string",
59 " Specifies the output file which will contains a model matrix. The output file will be in ",
63 " Specifies the input file which contains a matrix for feature selection purpose. This input ",
64 " file should be in .csr format. This option takes effect only when -fs option is specified.",
67 " Specifies the output file which will contain the top-n prediction for each user. The output",
68 " file wil be in .csr format. If this option is not specified, no prediction scores will be output.",
71 " Specifies the regularization parameter for the $\ell_1$ norm",
74 " Specifies the regularizationi parameter for the $\ell_2$ norm",
77 " Specifies the index of the first column (C-style indexing) from ",
78 " which the sparse coefficient matrix will be calculated. The default",
82 " Specifies the index of the last column (exclusively) up to which",
83 " the sparse coefficient matrix will be calculated. The default value",
84 " is the number of total columns. ",
87 " Specifies that the input feature selection matrix needs to be transposed.",
90 " Specifies that feature selection is required so as to accelerate the learning. ",
93 " Specifies the number of features if feature selection is applied. The default ",
97 " Specifies the debug level. The default value is 0.",
100 " Specifies the threshold which control the optimization. Once the error",
101 " from two optimization iterations is smaller than this value, the optimization",
102 " process will be terminated. The default value is 1e-5.",
104 " -max_bcls_niters=int",
105 " Specifies the maximum number of iterations that is allowed for optimization. ",
106 " Once the number of iterations reaches this value, the optimization process",
107 " will be terminated. The default value is 1e5.",
110 " Specifies the block size for output. Once the calculation for these bsize ",
111 " blocks are done, they are dumped into the output file. The default value is 1000.",
114 " Specifies the number of unique rating values in the testing set. The rating values",
115 " should be integers starting from 1. The default value is 1.",
118 " Specifies the number of recommendations to be produced for each user. The default",
122 " Print this message.",
131 static char shorthelpstr[][100] = {
133 " Usage: slim_learn [options] ",
134 " use 'slim_learn -help' for a summary of the options.",
148 int c = -1, option_index = -1;
153 while((c = gk_getopt_long_only(argc, argv,
"", slim_options, &option_index)) != -1){
174 ctrl->
dbglvl = atoi(gk_optarg);
178 ctrl->
lambda = atof(gk_optarg);
182 ctrl->
beta = atof(gk_optarg);
186 ctrl->
starti = atoi(gk_optarg);
190 ctrl->
endi = atoi(gk_optarg);
194 ctrl->
optTol = atof(gk_optarg);
206 ctrl->
fs_file = gk_strdup(gk_optarg);
210 ctrl->
k = atoi(gk_optarg);
214 ctrl->
bsize = atoi(gk_optarg);
222 ctrl->
topn = atoi(gk_optarg);
230 for (
int i=0; strlen(helpstr[i]) > 0; i++)
231 printf(
"%s\n", helpstr[i]);
237 printf(
"Illegal command-line option(s) %s\n", gk_optarg);
244 if (argc-gk_optind != 0 || argc == 1) {
245 for (
int i=0; strlen(shorthelpstr[i]) > 0; i++)
246 printf(
"%s\n", shorthelpstr[i]);