MCPcopy Index your code
hub / github.com/EdwardRaff/JSAT / train

Method train

JSAT/src/jsat/classifiers/linear/NewGLMNET.java:308–825  ·  view source on GitHub ↗
(ClassificationDataSet dataSet, Vec w_init, double b_init, boolean useInit)

Source from the content-addressed store, hash-verified

306 }
307
308 private void train(ClassificationDataSet dataSet, Vec w_init, double b_init, boolean useInit)
309 {
310 /*
311 * The original NewGLMNET paper describes the algorithm as minimizing
312 * f(w) = ||w||_1 + L(w), where L(w) is the logistic loss summed over
313 * all the variables. To make adapation to elastic net easier, we define
314 * f(w) = alpha ||w||_1 + L(w), where L(w) = (1-alpha) ||w||_2 + loss sum.
315 * This way we keep all the framework for L_1 regularization and
316 * shrinking, and just update the appropriate terms where necessary.
317 */
318
319 //paper uses n= #features so we will follow their lead
320 final int n = dataSet.getNumNumericalVars();
321 //l = # data points
322 final int l = dataSet.getSampleSize();
323
324 if(useInit)
325 {
326 w = new DenseVector(w_init);
327 b = useBias ? b_init : 0;
328 }
329 else
330 {
331 w = new DenseVector(n);
332 b = 0;
333 }
334 List<Vec> X = dataSet.getDataVectors();
335
336 double first_M_bar = 0;
337 double e_in = 1.0;//set later when first_M_bar is set
338
339 double[] w_dot_x = new double[l];
340 double[] exp_w_dot_x = new double[l];
341 double[] exp_w_dot_x_plus_dx = new double[l];
342 /**
343 * Used in the linear search step at the end
344 */
345 double[] d_dot_x = new double[l];
346 /**
347 * Contains the value 1/(1+e^(w^T x)). This is used in computing D and the partial derivatives.
348 */
349 double[] D_part = new double[l];
350 double[] D = new double[l];
351
352 /**
353 * Stores the value H<sup>k</sup><sub>j,j</sub> computer at the start of each iteration
354 */
355 double[] H = new double[n];
356 /**
357 * Stores the value H<sup>k</sup><sub>j,j</sub> computer at the start of
358 * each iteration for the bias term
359 */
360 double H_bias = 0;
361 /**
362 * Stores the value &nambla; L<sub>j</sub>
363 */
364 double[] delta_L = new double[n];
365 /**

Callers 1

trainCMethod · 0.95

Calls 15

addRangeMethod · 0.95
getM_Bar_for_w0Method · 0.95
sizeMethod · 0.95
getMethod · 0.95
clearMethod · 0.95
addAllMethod · 0.95
getNumNumericalVarsMethod · 0.80
getDataVectorsMethod · 0.80
getDataPointCategoryMethod · 0.80
expMethod · 0.80
getNumericColumnsMethod · 0.80
shuffleMethod · 0.80

Tested by

no test coverage detected