use of edu.stanford.nlp.optimization.LineSearcher in project CoreNLP by stanfordnlp.
the class CRFBiasedClassifier method adjustBias.
/**
* Adjust the bias parameter to optimize some objective function.
* Note that this function only tunes the bias parameter of one class
* (class of index 0), and is thus only useful for binary classification
* problems.
*/
public void adjustBias(List<List<IN>> develData, Function<Double, Double> evalFunction, double low, double high) {
LineSearcher ls = new GoldenSectionLineSearch(true, 1e-2, low, high);
CRFBiasedClassifierOptimizer optimizer = new CRFBiasedClassifierOptimizer(this, evalFunction);
double optVal = ls.minimize(optimizer);
int bi = featureIndex.indexOf(BIAS);
log.info("Class bias of " + weights[bi][0] + " reaches optimal value " + optVal);
}
Aggregations