MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / DCDs

Class DCDs

JSAT/src/jsat/classifiers/svm/DCDs.java:58–744  ·  view source on GitHub ↗

Implements Dual Coordinate Descent with shrinking (DCDs) training algorithms for a Linear L 1 or L 2 Support Vector Machine for binary classification and regression. NOTE: While this implementation makes use of the dual formulation only the linear kernel is ever used. The algorit

Source from the content-addressed store, hash-verified

56 * @see DCD
57 */
58public class DCDs implements BinaryScoreClassifier, Regressor, Parameterized, SingleWeightVectorModel, WarmClassifier, WarmRegressor
59{
60
61 private static final long serialVersionUID = -1686294187234524696L;
62 private int maxIterations;
63 private double tolerance;
64 private Vec[] vecs;
65 private double[] alpha;
66 private double[] y;
67 private double bias;
68 private Vec w;
69 private double C;
70 private boolean useL1;
71 private double eps = 0.001;
72
73 private boolean useBias = true;
74
75 private final List<Parameter> params = Collections.unmodifiableList(Parameter.getParamsFromMethods(this));
76 private final Map<String, Parameter> paramMap = Parameter.toParameterMap(params);
77
78 /**
79 * Creates a new DCDL2 SVM object
80 */
81 public DCDs()
82 {
83 this(10000, false);
84 }
85
86 /**
87 * Creates a new DCD SVM object
88 * @param maxIterations the maximum number of training iterations
89 * @param useL1 whether or not to use L1 or L2 form
90 */
91 public DCDs(int maxIterations, boolean useL1)
92 {
93 this(maxIterations, 1e-3, 1, useL1);
94 }
95
96 /**
97 * Creates a new DCD SVM object
98 * @param maxIterations the maximum number of training iterations
99 * @param tolerance the tolerance value for early stopping
100 * @param C the misclassification penalty
101 * @param useL1 whether or not to use L1 or L2 form
102 */
103 public DCDs(int maxIterations, double tolerance, double C, boolean useL1)
104 {
105 setMaxIterations(maxIterations);
106 setTolerance(tolerance);
107 setC(C);
108 setUseL1(useL1);
109 }
110
111 /**
112 * Sets the penalty parameter for misclassifications. The recommended value
113 * is 1, and values larger than 4 are not normally needed according to the
114 * original paper.
115 *

Callers

nothing calls this directly

Calls 2

getParamsFromMethodsMethod · 0.95
toParameterMapMethod · 0.95

Tested by

no test coverage detected