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

Class DCD

JSAT/src/jsat/classifiers/svm/DCD.java:53–516  ·  view source on GitHub ↗

Implements Dual Coordinate Descent (DCD) 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 algorithm also uses the

Source from the content-addressed store, hash-verified

51 * @see DCDs
52 */
53public class DCD implements BinaryScoreClassifier, Regressor, Parameterized, SingleWeightVectorModel
54{
55
56 private static final long serialVersionUID = -1489225034030922798L;
57 private int maxIterations;
58 private Vec[] vecs;
59 private double[] alpha;
60 private double[] y;
61 private double bias;
62 private Vec w;
63 private double C;
64 private boolean useL1;
65 private boolean onlineVersion = false;
66 private double eps = 0.001;
67 private boolean useBias = true;
68
69 private final List<Parameter> params = Collections.unmodifiableList(Parameter.getParamsFromMethods(this));
70 private final Map<String, Parameter> paramMap = Parameter.toParameterMap(params);
71
72 /**
73 * Creates a new DCDL2 SVM object
74 */
75 public DCD()
76 {
77 this(10000, false);
78 }
79
80 /**
81 * Creates a new DCD SVM object. The default C value of 1 is
82 * used as suggested in the original paper.
83 * @param maxIterations the maximum number of training iterations
84 * @param useL1 whether or not to use L1 or L2 form
85 */
86 public DCD(int maxIterations, boolean useL1)
87 {
88 this(maxIterations, 1, useL1);
89 }
90
91 /**
92 * Creates a new DCD SVM object
93 * @param maxIterations the maximum number of training iterations
94 * @param C the misclassification penalty
95 * @param useL1 whether or not to use L1 or L2 form
96 */
97 public DCD(int maxIterations, double C, boolean useL1)
98 {
99 this.maxIterations = maxIterations;
100 this.C = C;
101 this.useL1 = useL1;
102 }
103
104 /**
105 * By default, Algorithm 1 is used. Algorithm 2 is an "online" version
106 * that updates the dual form by only one data point at a time. This
107 * controls which version is used.
108 * @param onlineVersion <tt>false</tt> to use algorithm 1, <tt>true</tt>
109 * to use algorithm 2
110 */

Callers

nothing calls this directly

Calls 2

getParamsFromMethodsMethod · 0.95
toParameterMapMethod · 0.95

Tested by

no test coverage detected