use of de.lmu.ifi.dbs.elki.evaluation.scores.adapter.SimpleAdapter in project elki by elki-project.
the class OutlierRankingEvaluation method evaluateOrderingResult.
private EvaluationResult evaluateOrderingResult(int size, SetDBIDs positiveids, DBIDs order) {
if (order.size() != size) {
throw new IllegalStateException("Iterable result doesn't match database size - incomplete ordering?");
}
EvaluationResult res = new EvaluationResult("Evaluation of ranking", "ranking-evaluation");
DBIDsTest test = new DBIDsTest(positiveids);
double rate = positiveids.size() / (double) size;
MeasurementGroup g = res.newGroup("Evaluation measures:");
double rocauc = ROCEvaluation.STATIC.evaluate(test, new SimpleAdapter(order.iter()));
g.addMeasure("ROC AUC", rocauc, 0., 1., .5, false);
double avep = AveragePrecisionEvaluation.STATIC.evaluate(test, new SimpleAdapter(order.iter()));
g.addMeasure("Average Precision", avep, 0., 1., rate, false);
double rprec = PrecisionAtKEvaluation.RPRECISION.evaluate(test, new SimpleAdapter(order.iter()));
g.addMeasure("R-Precision", rprec, 0., 1., rate, false);
double maxf1 = MaximumF1Evaluation.STATIC.evaluate(test, new SimpleAdapter(order.iter()));
g.addMeasure("Maximum F1", maxf1, 0., 1., rate, false);
g = res.newGroup("Adjusted for chance:");
double adjauc = 2 * rocauc - 1;
g.addMeasure("Adjusted AUC", adjauc, 0., 1., 0., false);
double adjavep = (avep - rate) / (1 - rate);
g.addMeasure("Adjusted AveP", adjavep, 0., 1., 0., false);
double adjrprec = (rprec - rate) / (1 - rate);
g.addMeasure("Adjusted R-Prec", adjrprec, 0., 1., 0., false);
double adjmaxf1 = (maxf1 - rate) / (1 - rate);
g.addMeasure("Adjusted Max F1", adjmaxf1, 0., 1., 0., false);
if (LOG.isStatistics()) {
LOG.statistics(new DoubleStatistic(key + ".rocauc", rocauc));
LOG.statistics(new DoubleStatistic(key + ".rocauc.adjusted", adjauc));
LOG.statistics(new DoubleStatistic(key + ".precision.average", avep));
LOG.statistics(new DoubleStatistic(key + ".precision.average.adjusted", adjavep));
LOG.statistics(new DoubleStatistic(key + ".precision.r", rprec));
LOG.statistics(new DoubleStatistic(key + ".precision.r.adjusted", adjrprec));
LOG.statistics(new DoubleStatistic(key + ".f1.maximum", maxf1));
LOG.statistics(new DoubleStatistic(key + ".f1.maximum.adjusted", adjmaxf1));
}
return res;
}
use of de.lmu.ifi.dbs.elki.evaluation.scores.adapter.SimpleAdapter in project elki by elki-project.
the class OutlierROCCurve method computeROCResult.
private ROCResult computeROCResult(int size, SetDBIDs positiveids, DBIDs order) {
if (order.size() != size) {
throw new IllegalStateException("Iterable result doesn't match database size - incomplete ordering?");
}
XYCurve roccurve = ROCEvaluation.materializeROC(new DBIDsTest(positiveids), new SimpleAdapter(order.iter()));
double rocauc = XYCurve.areaUnderCurve(roccurve);
return new ROCResult(roccurve, rocauc);
}
Aggregations