in src/autotune.cc [277:306]
double Autotune::getMetricScore(
Meter& meter,
const metric_name& metricName,
const double metricValue,
const std::string& metricLabel) const {
double score = 0.0;
int32_t labelId = -1;
if (!metricLabel.empty()) {
labelId = fastText_->getLabelId(metricLabel);
if (labelId == -1) {
throw std::runtime_error("Unknown autotune metric label");
}
}
if (metricName == metric_name::f1score) {
score = meter.f1Score();
} else if (metricName == metric_name::f1scoreLabel) {
score = meter.f1Score(labelId);
} else if (metricName == metric_name::precisionAtRecall) {
score = meter.precisionAtRecall(metricValue);
} else if (metricName == metric_name::precisionAtRecallLabel) {
score = meter.precisionAtRecall(labelId, metricValue);
} else if (metricName == metric_name::recallAtPrecision) {
score = meter.recallAtPrecision(metricValue);
} else if (metricName == metric_name::recallAtPrecisionLabel) {
score = meter.recallAtPrecision(labelId, metricValue);
} else {
throw std::runtime_error("Unknown metric");
}
return score;
}