use of edu.neu.ccs.pyramid.regression.ConstantRegressor in project pyramid by cheng-li.
the class LSBoostOptimizer method addPriors.
@Override
protected void addPriors() {
double average = IntStream.range(0, dataSet.getNumDataPoints()).parallel().mapToDouble(i -> labels[i] * weights[i]).average().getAsDouble();
Regressor constant = new ConstantRegressor(average);
boosting.getEnsemble(0).add(constant);
}
use of edu.neu.ccs.pyramid.regression.ConstantRegressor in project pyramid by cheng-li.
the class PBoostOptimizer method addPriors.
@Override
protected void addPriors() {
double average = IntStream.range(0, dataSet.getNumDataPoints()).parallel().mapToDouble(i -> labels[i] * weights[i]).average().getAsDouble();
Regressor constant = new ConstantRegressor(average);
boosting.getEnsemble(0).add(constant);
}
use of edu.neu.ccs.pyramid.regression.ConstantRegressor in project pyramid by cheng-li.
the class IMLGradientBoostingTest method test5.
private static void test5() {
IMLGradientBoosting boosting = new IMLGradientBoosting(2);
boosting.addRegressor(new ConstantRegressor(1), 0);
boosting.addRegressor(new ConstantRegressor(-1), 1);
Vector vector = new DenseVector(2);
MultiLabel label1 = new MultiLabel().addLabel(0);
MultiLabel label2 = new MultiLabel().addLabel(1);
MultiLabel label3 = new MultiLabel();
MultiLabel label4 = new MultiLabel().addLabel(0).addLabel(1);
List<MultiLabel> assignments = new ArrayList<>();
assignments.add(label1);
assignments.add(label2);
// assignments.add(label3);
// assignments.add(label4);
boosting.setAssignments(assignments);
System.out.println(boosting.predictAssignmentProbWithoutConstraint(vector, label1));
System.out.println(boosting.predictAssignmentProbWithConstraint(vector, label1));
// for (MultiLabel multiLabel: boosting.getAssignments()){
// System.out.println("multilabel = "+multiLabel);
// System.out.println("prob = "+boosting.predictAssignmentProbWithConstraint(vector,multiLabel));
// }
}
use of edu.neu.ccs.pyramid.regression.ConstantRegressor 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);
}
}
use of edu.neu.ccs.pyramid.regression.ConstantRegressor 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);
}
Aggregations