Search in sources :

Example 6 with Regressor

use of edu.neu.ccs.pyramid.regression.Regressor in project pyramid by cheng-li.

the class LKBoostOptimizer method addPriors.

@Override
protected void addPriors() {
    PriorProbClassifier priorProbClassifier = new PriorProbClassifier(numClasses);
    priorProbClassifier.fit(dataSet, targetDistribution, weights);
    double[] probs = priorProbClassifier.getClassProbs();
    double[] scores = MathUtil.inverseSoftMax(probs);
    // weaken the priors
    for (int i = 0; i < scores.length; i++) {
        if (scores[i] > 5) {
            scores[i] = 5;
        }
        if (scores[i] < -5) {
            scores[i] = -5;
        }
    }
    for (int k = 0; k < numClasses; k++) {
        Regressor constant = new ConstantRegressor(scores[k]);
        boosting.getEnsemble(k).add(constant);
    }
}
Also used : PriorProbClassifier(edu.neu.ccs.pyramid.classification.PriorProbClassifier) Regressor(edu.neu.ccs.pyramid.regression.Regressor) ConstantRegressor(edu.neu.ccs.pyramid.regression.ConstantRegressor) ConstantRegressor(edu.neu.ccs.pyramid.regression.ConstantRegressor)

Example 7 with Regressor

use of edu.neu.ccs.pyramid.regression.Regressor in project pyramid by cheng-li.

the class AdaBoostMH method predictClassScore.

public double predictClassScore(Vector vector, int k) {
    List<Regressor> regressorsClassK = this.regressors.get(k);
    double score = 0;
    for (Regressor regressor : regressorsClassK) {
        score += regressor.predict(vector);
    }
    return score;
}
Also used : Regressor(edu.neu.ccs.pyramid.regression.Regressor)

Example 8 with Regressor

use of edu.neu.ccs.pyramid.regression.Regressor in project pyramid by cheng-li.

the class HMLGBTrainer method iterate.

public void iterate() {
    for (int k = 0; k < this.boosting.getNumClasses(); k++) {
        /**
             * parallel by feature
             */
        Regressor regressor = this.fitClassK(k);
        this.boosting.addRegressor(regressor, k);
        /**
             * parallel by data
             */
        this.updateClassScores(regressor, k);
    }
    /**
         * parallel by data
         */
    this.updateAssignmentProbMatrix();
    this.updateProbabilityMatrix();
    this.updateClassGradientMatrix();
}
Also used : Regressor(edu.neu.ccs.pyramid.regression.Regressor) ConstantRegressor(edu.neu.ccs.pyramid.regression.ConstantRegressor)

Example 9 with Regressor

use of edu.neu.ccs.pyramid.regression.Regressor in project pyramid by cheng-li.

the class HMLGradientBoosting method predictClassScore.

/**
     *
     * @param vector
     * @param k class index
     * @return
     */
public double predictClassScore(Vector vector, int k) {
    List<Regressor> regressorsClassK = this.regressors.get(k);
    double score = 0;
    for (Regressor regressor : regressorsClassK) {
        score += regressor.predict(vector);
    }
    return score;
}
Also used : Regressor(edu.neu.ccs.pyramid.regression.Regressor)

Example 10 with Regressor

use of edu.neu.ccs.pyramid.regression.Regressor in project pyramid by cheng-li.

the class MBoostOptimizer method addPriors.

@Override
protected void addPriors() {
    double median = MathUtil.weightedMedian(labels, weights);
    Regressor constant = new ConstantRegressor(median);
    boosting.getEnsemble(0).add(constant);
}
Also used : Regressor(edu.neu.ccs.pyramid.regression.Regressor) ConstantRegressor(edu.neu.ccs.pyramid.regression.ConstantRegressor) ConstantRegressor(edu.neu.ccs.pyramid.regression.ConstantRegressor)

Aggregations

Regressor (edu.neu.ccs.pyramid.regression.Regressor)17 ConstantRegressor (edu.neu.ccs.pyramid.regression.ConstantRegressor)11 PriorProbClassifier (edu.neu.ccs.pyramid.classification.PriorProbClassifier)1 LKBoost (edu.neu.ccs.pyramid.classification.lkboost.LKBoost)1 LabelTranslator (edu.neu.ccs.pyramid.dataset.LabelTranslator)1 Feature (edu.neu.ccs.pyramid.feature.Feature)1 TopFeatures (edu.neu.ccs.pyramid.feature.TopFeatures)1 RegTreeInspector (edu.neu.ccs.pyramid.regression.regression_tree.RegTreeInspector)1 RegressionTree (edu.neu.ccs.pyramid.regression.regression_tree.RegressionTree)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1