use of edu.neu.ccs.pyramid.regression.regression_tree.RegTreeFactory in project pyramid by cheng-li.
the class LSLogisticBoostTest method test1.
private static void test1() {
RegDataSet regDataSet = RegDataSetBuilder.getBuilder().numDataPoints(10000).numFeatures(2).build();
for (int i = 0; i < regDataSet.getNumDataPoints(); i++) {
double r = Math.random();
double s = Math.random();
regDataSet.setFeatureValue(i, 0, r);
regDataSet.setFeatureValue(i, 0, s);
if (r + s < 0.1) {
regDataSet.setLabel(i, 2);
} else {
regDataSet.setLabel(i, -2);
}
}
LSLogisticBoost lsLogisticBoost = new LSLogisticBoost();
RegTreeConfig regTreeConfig = new RegTreeConfig().setMaxNumLeaves(10);
RegTreeFactory regTreeFactory = new RegTreeFactory(regTreeConfig);
LSLogisticBoostOptimizer optimizer = new LSLogisticBoostOptimizer(lsLogisticBoost, regDataSet, regTreeFactory);
optimizer.setShrinkage(100);
optimizer.initialize();
for (int i = 0; i < 100; i++) {
System.out.println("training rmse = " + RMSE.rmse(lsLogisticBoost, regDataSet));
optimizer.iterate();
}
for (int i = 0; i < 1000; i++) {
System.out.println(regDataSet.getLabels()[i] + " " + lsLogisticBoost.predict(regDataSet.getRow(i)));
}
// System.out.println("********************** LSBOOST **************");
// LSBoost lsBoost = new LSBoost();
// LSBoostOptimizer lsBoostOptimizer = new LSBoostOptimizer(lsBoost,regDataSet,regTreeFactory);
// lsBoostOptimizer.initialize();
// for (int i=0;i<100;i++){
// System.out.println("training rmse = "+ RMSE.rmse(lsBoost,regDataSet));
// lsBoostOptimizer.iterate();
// }
//
// for (int i=0;i<1000;i++){
// System.out.println(regDataSet.getLabels()[i]+" "+lsBoost.predict(regDataSet.getRow(i)));
// }
}
use of edu.neu.ccs.pyramid.regression.regression_tree.RegTreeFactory in project pyramid by cheng-li.
the class LSBoostTest method test1.
private static void test1() throws Exception {
RegDataSet trainSet = TRECFormat.loadRegDataSet(new File("/Users/chengli/Dropbox/Public/pyramid/abalone//train"), DataSetType.REG_DENSE, true);
RegDataSet testSet = TRECFormat.loadRegDataSet(new File("/Users/chengli/Dropbox/Public/pyramid/abalone//test"), DataSetType.REG_DENSE, true);
LSBoost lsBoost = new LSBoost();
RegTreeConfig regTreeConfig = new RegTreeConfig().setMaxNumLeaves(3);
RegTreeFactory regTreeFactory = new RegTreeFactory(regTreeConfig);
LSBoostOptimizer optimizer = new LSBoostOptimizer(lsBoost, trainSet, regTreeFactory);
optimizer.setShrinkage(0.1);
optimizer.initialize();
for (int i = 0; i < 10; i++) {
System.out.println("iteration " + i);
System.out.println("train RMSE = " + RMSE.rmse(lsBoost, trainSet));
System.out.println("test RMSE = " + RMSE.rmse(lsBoost, testSet));
optimizer.iterate();
}
}
use of edu.neu.ccs.pyramid.regression.regression_tree.RegTreeFactory in project pyramid by cheng-li.
the class CBMOptimizer method updateMultiClassBoost.
private void updateMultiClassBoost() {
int numComponents = cbm.numComponents;
int numIterations = numIterationsMultiClass;
double shrinkage = shrinkageMultiClass;
LKBoost boost = (LKBoost) this.cbm.multiClassClassifier;
RegTreeConfig regTreeConfig = new RegTreeConfig().setMaxNumLeaves(numLeavesMultiClass);
RegTreeFactory regTreeFactory = new RegTreeFactory(regTreeConfig);
regTreeFactory.setLeafOutputCalculator(new LKBOutputCalculator(numComponents));
LKBoostOptimizer optimizer = new LKBoostOptimizer(boost, dataSet, regTreeFactory, gammas);
optimizer.setShrinkage(shrinkage);
optimizer.initialize();
optimizer.iterate(numIterations);
}
Aggregations