use of edu.neu.ccs.pyramid.regression.ConstantRegressor in project pyramid by cheng-li.
the class HMLGBTrainer method setPriorProbs.
//========================= PRIVATE ==============================
/**
* not sure whether this is good for performance
* start with prior probabilities
* should be called before setTrainConfig
* @param probs
*/
private void setPriorProbs(double[] probs) {
if (probs.length != this.boosting.getNumClasses()) {
throw new IllegalArgumentException("probs.length!=this.numClasses");
}
double average = Arrays.stream(probs).map(Math::log).average().getAsDouble();
for (int k = 0; k < this.boosting.getNumClasses(); k++) {
double score = Math.log(probs[k] - average);
Regressor constant = new ConstantRegressor(score);
this.boosting.addRegressor(constant, k);
}
}
use of edu.neu.ccs.pyramid.regression.ConstantRegressor in project pyramid by cheng-li.
the class LADBoostOptimizer method addPriors.
@Override
protected void addPriors() {
double median = MathUtil.weightedMedian(labels, weights);
Regressor constant = new ConstantRegressor(median);
boosting.getEnsemble(0).add(constant);
}
use of edu.neu.ccs.pyramid.regression.ConstantRegressor in project pyramid by cheng-li.
the class IMLGBTrainer method setPriorProbs.
// public void setActiveFeatures(int[] activeFeatures) {
// this.config.setActiveFeatures(activeFeatures);
// }
//
// public void setActiveDataPoints(int[] activeDataPoints) {
// this.config.setActiveDataPoints(activeDataPoints);
// }
//========================== PRIVATE ============================
/**
* not sure whether this is good for performance
* start with prior probabilities
* should be called before setTrainConfig
* @param probs
*/
private void setPriorProbs(double[] probs) {
if (probs.length != this.boosting.getNumClasses()) {
throw new IllegalArgumentException("probs.length!=this.numClasses");
}
for (int k = 0; k < this.boosting.getNumClasses(); k++) {
double score = MathUtil.inverseSigmoid(probs[k]);
// we don't want the prior to be overly strong
double soft = Math.sqrt(Math.abs(score));
if (score < 0) {
soft = -soft;
}
Regressor constant = new ConstantRegressor(soft);
this.boosting.addRegressor(constant, k);
}
}
use of edu.neu.ccs.pyramid.regression.ConstantRegressor in project pyramid by cheng-li.
the class AdaBoostMHTrainer method setPriorProbs.
private void setPriorProbs(double[] probs) {
if (probs.length != this.boosting.getNumClasses()) {
throw new IllegalArgumentException("probs.length!=this.numClasses");
}
double average = Arrays.stream(probs).map(Math::log).average().getAsDouble();
for (int k = 0; k < this.boosting.getNumClasses(); k++) {
double score = Math.log(probs[k] - average);
Regressor constant = new ConstantRegressor(score);
this.boosting.addRegressor(constant, k);
}
}
Aggregations