Skip to content

Commit 77c89d9

Browse files
committed
Port "- add max Newton iter warning in newton.cpp"
Ported from cjlin1/liblinear@7b0193b
1 parent 0a3b8dd commit 77c89d9

File tree

3 files changed

+32
-25
lines changed

3 files changed

+32
-25
lines changed

src/main/java/de/bwaldvogel/liblinear/Newton.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ void newton(double[] w) {
8989

9090
iter++;
9191
}
92+
93+
if (iter >= max_iter)
94+
info("%nWARNING: reaching max number of Newton iterations%n");
9295
}
9396

9497
private int pcg(double[] g, double[] M, double[] s, double[] r) {

src/main/java/de/bwaldvogel/liblinear/Parameter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public final class Parameter implements Cloneable {
77

88
double C;
99

10-
/** stopping criteria */
10+
/** stopping tolerance */
1111
double eps;
1212

1313
int max_iters = 1000; // maximal iterations

src/main/java/de/bwaldvogel/liblinear/Train.java

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,37 +97,41 @@ private void exit_with_help() {
9797
+ "options:%n"
9898
+ "-s type : set type of solver (default 1)%n"
9999
+ " for multi-class classification%n"
100-
+ " 0 -- L2-regularized logistic regression (primal)%n"
101-
+ " 1 -- L2-regularized L2-loss support vector classification (dual)%n"
102-
+ " 2 -- L2-regularized L2-loss support vector classification (primal)%n"
103-
+ " 3 -- L2-regularized L1-loss support vector classification (dual)%n"
104-
+ " 4 -- support vector classification by Crammer and Singer%n"
105-
+ " 5 -- L1-regularized L2-loss support vector classification%n"
106-
+ " 6 -- L1-regularized logistic regression%n"
107-
+ " 7 -- L2-regularized logistic regression (dual)%n"
100+
+ " 0 -- L2-regularized logistic regression (primal)%n"
101+
+ " 1 -- L2-regularized L2-loss support vector classification (dual)%n"
102+
+ " 2 -- L2-regularized L2-loss support vector classification (primal)%n"
103+
+ " 3 -- L2-regularized L1-loss support vector classification (dual)%n"
104+
+ " 4 -- support vector classification by Crammer and Singer%n"
105+
+ " 5 -- L1-regularized L2-loss support vector classification%n"
106+
+ " 6 -- L1-regularized logistic regression%n"
107+
+ " 7 -- L2-regularized logistic regression (dual)%n"
108108
+ " for regression%n"
109-
+ " 11 -- L2-regularized L2-loss support vector regression (primal)%n"
110-
+ " 12 -- L2-regularized L2-loss support vector regression (dual)%n"
111-
+ " 13 -- L2-regularized L1-loss support vector regression (dual)%n"
109+
+ " 11 -- L2-regularized L2-loss support vector regression (primal)%n"
110+
+ " 12 -- L2-regularized L2-loss support vector regression (dual)%n"
111+
+ " 13 -- L2-regularized L1-loss support vector regression (dual)%n"
112+
+ " for outlier detection%n"
113+
+ " 21 -- one-class support vector machine (dual)%n"
112114
+ "-c cost : set the parameter C (default 1)%n"
113115
+ "-p epsilon : set the epsilon in loss function of SVR (default 0.1)%n"
114116
+ "-n nu : set the parameter nu of one-class SVM (default 0.5)%n"
115117
+ "-e epsilon : set tolerance of termination criterion%n"
116-
+ " -s 0 and 2%n" + " |f'(w)|_2 <= eps*min(pos,neg)/l*|f'(w0)|_2,%n"
117-
+ " where f is the primal function and pos/neg are # of%n"
118-
+ " positive/negative data (default 0.01)%n" + " -s 11%n"
119-
+ " |f'(w)|_2 <= eps*|f'(w0)|_2 (default 0.0001)%n"
120-
+ " -s 1, 3, 4, 7, and 21%n"
121-
+ " Dual maximal violation <= eps; similar to libsvm (default 0.1 except 0.01 for -s 21)%n"
122-
+ " -s 5 and 6%n"
123-
+ " |f'(w)|_1 <= eps*min(pos,neg)/l*|f'(w0)|_1,%n"
124-
+ " where f is the primal function (default 0.01)%n"
125-
+ " -s 12 and 13%n"
126-
+ " |f'(alpha)|_1 <= eps |f'(alpha0)|,%n"
127-
+ " where f is the dual function (default 0.1)%n"
118+
+ " -s 0 and 2%n"
119+
+ " |f'(w)|_2 <= eps*min(pos,neg)/l*|f'(w0)|_2,%n"
120+
+ " where f is the primal function and pos/neg are # of%n"
121+
+ " positive/negative data (default 0.01)%n"
122+
+ " -s 11%n"
123+
+ " |f'(w)|_2 <= eps*|f'(w0)|_2 (default 0.0001)%n"
124+
+ " -s 1, 3, 4, 7, and 21%n"
125+
+ " Dual maximal violation <= eps; similar to libsvm (default 0.1 except 0.01 for -s 21)%n"
126+
+ " -s 5 and 6%n"
127+
+ " |f'(w)|_1 <= eps*min(pos,neg)/l*|f'(w0)|_1,%n"
128+
+ " where f is the primal function (default 0.01)%n"
129+
+ " -s 12 and 13%n"
130+
+ " |f'(alpha)|_1 <= eps |f'(alpha0)|,%n"
131+
+ " where f is the dual function (default 0.1)%n"
128132
+ "-B bias : if bias >= 0, instance x becomes [x; bias]; if < 0, no bias term added (default -1)%n"
129133
+ "-R : not regularize the bias; must with -B 1 to have the bias; DON'T use this unless you know what it is%n"
130-
+ " (for -s 0, 2, 5, 6, 11)%n"
134+
+ " (for -s 0, 2, 5, 6, 11)%n"
131135
+ "-wi weight: weights adjust the parameter C of different classes (see README for details)%n"
132136
+ "-v n: n-fold cross validation mode%n"
133137
+ "-C : find parameters (C for -s 0, 2 and C, p for -s 11)%n"

0 commit comments

Comments
 (0)