public ElasticBandPrior(double alphaByLambda) { this.alphaByLambda = alphaByLambda; l1 = new L1(); l2 = new L2(1); }
@Override public double logP(double betaIJ) { return l1.logP(betaIJ) + alphaByLambda * l2.logP(betaIJ); }
@Override public void readFields(DataInput in) throws IOException { alphaByLambda = in.readDouble(); l1 = new L1(); l1.readFields(in); l2 = new L2(); l2.readFields(in); } }
@Override public void write(DataOutput out) throws IOException { out.writeDouble(alphaByLambda); l1.write(out); l2.write(out); }
@Override public void write(DataOutput out) throws IOException { out.writeDouble(alphaByLambda); l1.write(out); l2.write(out); }
public ElasticBandPrior(double alphaByLambda) { this.alphaByLambda = alphaByLambda; l1 = new L1(); l2 = new L2(1); }
@Override public void readFields(DataInput in) throws IOException { alphaByLambda = in.readDouble(); l1 = new L1(); l1.readFields(in); l2 = new L2(); l2.readFields(in); } }
@Override public void write(DataOutput out) throws IOException { out.writeDouble(alphaByLambda); l1.write(out); l2.write(out); }
@Override public double logP(double betaIJ) { return l1.logP(betaIJ) + alphaByLambda * l2.logP(betaIJ); }
public ElasticBandPrior(double alphaByLambda) { this.alphaByLambda = alphaByLambda; l1 = new L1(); l2 = new L2(1); }
@Override public void readFields(DataInput in) throws IOException { alphaByLambda = in.readDouble(); l1 = new L1(); l1.readFields(in); l2 = new L2(); l2.readFields(in); } }
@Override public double logP(double betaIJ) { return l1.logP(betaIJ) + alphaByLambda * l2.logP(betaIJ); }
throw new BadClassifierSpecException("Must have more than one target category. Remember that categories is a space separated list"); model = new OnlineLogisticRegression(categories.size(), Integer.parseInt(options.get("features")), new L1()); options.remove("categories"); options.remove("features");
OnlineLogisticRegression learningAlgo = new OnlineLogisticRegression(2, 3, new L1());
learningAlgo = new OnlineLogisticRegression(2, 3, new L1()); learningAlgo.lambda(0.1); learningAlgo.learningRate(10);
20, FEATURES, new L1()) .alpha(1).stepOffset(1000) .decayExponent(0.9)
private PriorFunction getPrior() { switch(prior) { case L1: return new L1(); case L2: return prior.custom ? new L2(prior.param) : new L2(); case elastic: return prior.custom ? new ElasticBandPrior(prior.param) : new ElasticBandPrior(); case uniform: return new UniformPrior(); case t: if (!prior.custom) throw new IllegalArgumentException("Must specify df with 'priorParam' in config to use T prior function."); return new TPrior(prior.param); case unknown: return new L2(1); default: return new L2(1); } }
AdaptiveLogisticRegression learningAlgorithm = new AdaptiveLogisticRegression(20, FEATURES, new L1()); learningAlgorithm.setInterval(800); learningAlgorithm.setAveragingWindow(500);
OnlineLogisticRegression lr = new OnlineLogisticRegression(2, 8, new L1()) .lambda(1 * 1.0e-3) .stepOffset(11)
@Test public void testTrain() throws Exception { Vector target = readStandardData(); // lambda here needs to be relatively small to avoid swamping the actual signal, but can be // larger than usual because the data are dense. The learning rate doesn't matter too much // for this example, but should generally be < 1 // --passes 1 --rate 50 --lambda 0.001 --input sgd-y.csv --features 21 --output model --noBias // --target y --categories 2 --predictors V2 V3 V4 V5 V6 V7 --types n OnlineLogisticRegression lr = new OnlineLogisticRegression(2, 8, new L1()) .lambda(1 * 1.0e-3) .learningRate(50); train(getInput(), target, lr); test(getInput(), target, lr, 0.05, 0.3); }