]> granicus.if.org Git - liblinear/commitdiff
- add max Newton iter warning in newton.cpp
authorChih-Jen Lin <cjlin@csie.ntu.edu.tw>
Tue, 20 Oct 2020 23:43:05 +0000 (07:43 +0800)
committerChih-Jen Lin <cjlin@csie.ntu.edu.tw>
Tue, 20 Oct 2020 23:43:05 +0000 (07:43 +0800)
- in code comments replace tabs with spaces

linear.h
newton.cpp
predict.c
train.c

index bfd5e1c82bb87226c10b18c1745e5a684c1b36f2..c27c23a6b57e8f0e194e9c62aad5950174bf0999 100644 (file)
--- a/linear.h
+++ b/linear.h
@@ -30,7 +30,7 @@ struct parameter
        int solver_type;
 
        /* these are for training only */
-       double eps;             /* stopping criteria */
+       double eps;             /* stopping tolerance */
        double C;
        int nr_weight;
        int *weight_label;
@@ -44,12 +44,12 @@ struct parameter
 struct model
 {
        struct parameter param;
-       int nr_class;           /* number of classes */
+       int nr_class;           /* number of classes */
        int nr_feature;
        double *w;
-       int *label;             /* label of each class */
+       int *label;             /* label of each class */
        double bias;
-       double rho;             /* one-class SVM only */
+       double rho;             /* one-class SVM only */
 };
 
 struct model* train(const struct problem *prob, const struct parameter *param);
index 17ba7deaeec543f2591d4cd89667841fb3576ffa..bb2c3b1e9d36cf62efe4ab83c117d06d78e07962 100644 (file)
@@ -162,6 +162,9 @@ void NEWTON::newton(double *w)
                iter++;
        }
 
+       if(iter >= max_iter)
+               info("\nWARNING: reaching max number of Newton iterations\n");
+
        delete[] g;
        delete[] r;
        delete[] s;
index 8f415d27751255423d58e1342065814f48b6c23e..85ed067c6c17f5cb9f08dc6280d0201dbfb4f085 100644 (file)
--- a/predict.c
+++ b/predict.c
@@ -97,7 +97,7 @@ void do_predict(FILE *input, FILE *output)
 
                while(1)
                {
-                       if(i>=max_nr_attr-2)    // need one more for index = -1
+                       if(i>=max_nr_attr-2)    // need one more for index = -1
                        {
                                max_nr_attr *= 2;
                                x = (struct feature_node *) realloc(x,max_nr_attr*sizeof(struct feature_node));
diff --git a/train.c b/train.c
index ef8fe70142dab5a5895e901ed9b7e205a118e8d4..7923a8d3124d7add1d836cca0cd2adfcfc93150e 100644 (file)
--- a/train.c
+++ b/train.c
@@ -17,41 +17,41 @@ void exit_with_help()
        "options:\n"
        "-s type : set type of solver (default 1)\n"
        "  for multi-class classification\n"
-       "        0 -- L2-regularized logistic regression (primal)\n"
-       "        1 -- L2-regularized L2-loss support vector classification (dual)\n"
-       "        2 -- L2-regularized L2-loss support vector classification (primal)\n"
-       "        3 -- L2-regularized L1-loss support vector classification (dual)\n"
-       "        4 -- support vector classification by Crammer and Singer\n"
-       "        5 -- L1-regularized L2-loss support vector classification\n"
-       "        6 -- L1-regularized logistic regression\n"
-       "        7 -- L2-regularized logistic regression (dual)\n"
+       "        0 -- L2-regularized logistic regression (primal)\n"
+       "        1 -- L2-regularized L2-loss support vector classification (dual)\n"
+       "        2 -- L2-regularized L2-loss support vector classification (primal)\n"
+       "        3 -- L2-regularized L1-loss support vector classification (dual)\n"
+       "        4 -- support vector classification by Crammer and Singer\n"
+       "        5 -- L1-regularized L2-loss support vector classification\n"
+       "        6 -- L1-regularized logistic regression\n"
+       "        7 -- L2-regularized logistic regression (dual)\n"
        "  for regression\n"
-       "       11 -- L2-regularized L2-loss support vector regression (primal)\n"
-       "       12 -- L2-regularized L2-loss support vector regression (dual)\n"
-       "       13 -- L2-regularized L1-loss support vector regression (dual)\n"
+       "       11 -- L2-regularized L2-loss support vector regression (primal)\n"
+       "       12 -- L2-regularized L2-loss support vector regression (dual)\n"
+       "       13 -- L2-regularized L1-loss support vector regression (dual)\n"
        "  for outlier detection\n"
-       "       21 -- one-class support vector machine (dual)\n"
+       "       21 -- one-class support vector machine (dual)\n"
        "-c cost : set the parameter C (default 1)\n"
        "-p epsilon : set the epsilon in loss function of SVR (default 0.1)\n"
        "-n nu : set the parameter nu of one-class SVM (default 0.5)\n"
        "-e epsilon : set tolerance of termination criterion\n"
-       "       -s 0 and 2\n"
-       "               |f'(w)|_2 <= eps*min(pos,neg)/l*|f'(w0)|_2,\n"
-       "               where f is the primal function and pos/neg are # of\n"
-       "               positive/negative data (default 0.01)\n"
-       "       -s 11\n"
-       "               |f'(w)|_2 <= eps*|f'(w0)|_2 (default 0.0001)\n"
-       "       -s 1, 3, 4, 7, and 21\n"
-       "               Dual maximal violation <= eps; similar to libsvm (default 0.1 except 0.01 for -s 21)\n"
-       "       -s 5 and 6\n"
-       "               |f'(w)|_1 <= eps*min(pos,neg)/l*|f'(w0)|_1,\n"
-       "               where f is the primal function (default 0.01)\n"
-       "       -s 12 and 13\n"
-       "               |f'(alpha)|_1 <= eps |f'(alpha0)|,\n"
-       "               where f is the dual function (default 0.1)\n"
+       "       -s 0 and 2\n"
+       "               |f'(w)|_2 <= eps*min(pos,neg)/l*|f'(w0)|_2,\n"
+       "               where f is the primal function and pos/neg are # of\n"
+       "               positive/negative data (default 0.01)\n"
+       "       -s 11\n"
+       "               |f'(w)|_2 <= eps*|f'(w0)|_2 (default 0.0001)\n"
+       "       -s 1, 3, 4, 7, and 21\n"
+       "               Dual maximal violation <= eps; similar to libsvm (default 0.1 except 0.01 for -s 21)\n"
+       "      -s 5 and 6\n"
+       "               |f'(w)|_1 <= eps*min(pos,neg)/l*|f'(w0)|_1,\n"
+       "               where f is the primal function (default 0.01)\n"
+       "       -s 12 and 13\n"
+       "               |f'(alpha)|_1 <= eps |f'(alpha0)|,\n"
+       "               where f is the dual function (default 0.1)\n"
        "-B bias : if bias >= 0, instance x becomes [x; bias]; if < 0, no bias term added (default -1)\n"
        "-R : not regularize the bias; must with -B 1 to have the bias; DON'T use this unless you know what it is\n"
-       "       (for -s 0, 2, 5, 6, 11)\n"
+       "       (for -s 0, 2, 5, 6, 11)\n"
        "-wi weight: weights adjust the parameter C of different classes (see README for details)\n"
        "-v n: n-fold cross validation mode\n"
        "-C : find parameters (C for -s 0, 2 and C, p for -s 11)\n"
@@ -211,7 +211,7 @@ void do_cross_validation()
 void parse_command_line(int argc, char **argv, char *input_file_name, char *model_file_name)
 {
        int i;
-       void (*print_func)(const char*) = NULL; // default printing to stdout
+       void (*print_func)(const char*) = NULL;  // default printing to stdout
 
        // default values
        param.solver_type = L2R_L2LOSS_SVC_DUAL;