Search in sources :

Example 11 with LKBoost

use of edu.neu.ccs.pyramid.classification.lkboost.LKBoost in project pyramid by cheng-li.

the class GBCBMOptimizer method updateBinaryClassifier.

@Override
protected void updateBinaryClassifier(int component, int label, MultiLabelClfDataSet activeDataset, double[] activeGammas) {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    if (cbm.binaryClassifiers[component][label] == null || cbm.binaryClassifiers[component][label] instanceof PriorProbClassifier) {
        cbm.binaryClassifiers[component][label] = new LKBoost(2);
    }
    int[] binaryLabels = DataSetUtil.toBinaryLabels(activeDataset.getMultiLabels(), label);
    double[][] targetsDistributions = DataSetUtil.labelsToDistributions(binaryLabels, 2);
    LKBoost boost = (LKBoost) this.cbm.binaryClassifiers[component][label];
    RegTreeConfig regTreeConfig = new RegTreeConfig().setMaxNumLeaves(numLeaves);
    RegTreeFactory regTreeFactory = new RegTreeFactory(regTreeConfig);
    regTreeFactory.setLeafOutputCalculator(new LKBOutputCalculator(2));
    LKBoostOptimizer optimizer = new LKBoostOptimizer(boost, activeDataset, regTreeFactory, activeGammas, targetsDistributions);
    optimizer.setShrinkage(shrinkage);
    optimizer.initialize();
    optimizer.iterate(binaryUpdatesPerIter);
    if (logger.isDebugEnabled()) {
        logger.debug("time spent on updating component " + component + " label " + label + " = " + stopWatch);
    }
}
Also used : LKBoostOptimizer(edu.neu.ccs.pyramid.classification.lkboost.LKBoostOptimizer) RegTreeConfig(edu.neu.ccs.pyramid.regression.regression_tree.RegTreeConfig) RegTreeFactory(edu.neu.ccs.pyramid.regression.regression_tree.RegTreeFactory) LKBOutputCalculator(edu.neu.ccs.pyramid.classification.lkboost.LKBOutputCalculator) PriorProbClassifier(edu.neu.ccs.pyramid.classification.PriorProbClassifier) StopWatch(org.apache.commons.lang3.time.StopWatch) LKBoost(edu.neu.ccs.pyramid.classification.lkboost.LKBoost)

Aggregations

LKBoost (edu.neu.ccs.pyramid.classification.lkboost.LKBoost)11 LKBOutputCalculator (edu.neu.ccs.pyramid.classification.lkboost.LKBOutputCalculator)10 LKBoostOptimizer (edu.neu.ccs.pyramid.classification.lkboost.LKBoostOptimizer)10 RegTreeConfig (edu.neu.ccs.pyramid.regression.regression_tree.RegTreeConfig)10 RegTreeFactory (edu.neu.ccs.pyramid.regression.regression_tree.RegTreeFactory)10 ClfDataSet (edu.neu.ccs.pyramid.dataset.ClfDataSet)2 DataSetType (edu.neu.ccs.pyramid.dataset.DataSetType)2 File (java.io.File)2 PriorProbClassifier (edu.neu.ccs.pyramid.classification.PriorProbClassifier)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1