use of de.lmu.ifi.dbs.elki.database.ids.SetDBIDs in project elki by elki-project.
the class OutlierSmROCCurve method processNewResult.
@Override
public void processNewResult(ResultHierarchy hier, Result result) {
Database db = ResultUtil.findDatabase(hier);
// Prepare
SetDBIDs positiveids = DBIDUtil.ensureSet(DatabaseUtil.getObjectsByLabelMatch(db, positiveClassName));
if (positiveids.size() == 0) {
LOG.warning("Computing a ROC curve failed - no objects matched.");
return;
}
List<OutlierResult> oresults = OutlierResult.getOutlierResults(result);
List<OrderingResult> orderings = ResultUtil.getOrderingResults(result);
for (OutlierResult o : oresults) {
db.getHierarchy().add(o, computeSmROCResult(positiveids, o));
orderings.remove(o.getOrdering());
}
}
use of de.lmu.ifi.dbs.elki.database.ids.SetDBIDs in project elki by elki-project.
the class OutlierPrecisionRecallCurve method processNewResult.
@Override
public void processNewResult(ResultHierarchy hier, Result result) {
Database db = ResultUtil.findDatabase(hier);
// Prepare
SetDBIDs positiveids = DBIDUtil.ensureSet(DatabaseUtil.getObjectsByLabelMatch(db, positiveClassName));
if (positiveids.size() == 0) {
LOG.warning("Computing a P/R curve failed - no objects matched.");
return;
}
List<OutlierResult> oresults = OutlierResult.getOutlierResults(result);
List<OrderingResult> orderings = ResultUtil.getOrderingResults(result);
// Outlier results are the main use case.
for (OutlierResult o : oresults) {
DBIDs sorted = o.getOrdering().order(o.getOrdering().getDBIDs());
PRCurve curve = computePrecisionResult(o.getScores().size(), positiveids, sorted.iter(), o.getScores());
db.getHierarchy().add(o, curve);
EvaluationResult ev = EvaluationResult.findOrCreate(db.getHierarchy(), o, "Evaluation of ranking", "ranking-evaluation");
ev.findOrCreateGroup("Evaluation measures").addMeasure(PRAUC_LABEL, curve.getAUC(), 0., 1., false);
// Process them only once.
orderings.remove(o.getOrdering());
}
// otherwise apply an ordering to the database IDs.
for (OrderingResult or : orderings) {
DBIDs sorted = or.order(or.getDBIDs());
PRCurve curve = computePrecisionResult(or.getDBIDs().size(), positiveids, sorted.iter(), null);
db.getHierarchy().add(or, curve);
EvaluationResult ev = EvaluationResult.findOrCreate(db.getHierarchy(), or, "Evaluation of ranking", "ranking-evaluation");
ev.findOrCreateGroup("Evaluation measures").addMeasure(PRAUC_LABEL, curve.getAUC(), 0., 1., false);
}
}
use of de.lmu.ifi.dbs.elki.database.ids.SetDBIDs in project elki by elki-project.
the class OutlierRankingEvaluation method processNewResult.
@Override
public void processNewResult(ResultHierarchy hier, Result result) {
Database db = ResultUtil.findDatabase(hier);
SetDBIDs positiveids = DBIDUtil.ensureSet(DatabaseUtil.getObjectsByLabelMatch(db, positiveClassName));
if (positiveids.size() == 0) {
LOG.warning("Cannot evaluate outlier results - no objects matched the given pattern.");
return;
}
boolean nonefound = true;
List<OutlierResult> oresults = OutlierResult.getOutlierResults(result);
List<OrderingResult> orderings = ResultUtil.getOrderingResults(result);
// Outlier results are the main use case.
for (OutlierResult o : oresults) {
db.getHierarchy().add(o, evaluateOutlierResult(o.getScores().size(), positiveids, o));
// Process them only once.
orderings.remove(o.getOrdering());
nonefound = false;
}
// otherwise apply an ordering to the database IDs.
for (OrderingResult or : orderings) {
DBIDs sorted = or.order(or.getDBIDs());
db.getHierarchy().add(or, evaluateOrderingResult(or.getDBIDs().size(), positiveids, sorted));
nonefound = false;
}
if (nonefound) {
return;
// LOG.warning("No results found to process with ROC curve analyzer. Got
// "+iterables.size()+" iterables, "+orderings.size()+" orderings.");
}
}
use of de.lmu.ifi.dbs.elki.database.ids.SetDBIDs in project elki by elki-project.
the class OutlierPrecisionAtKCurve method processNewResult.
@Override
public void processNewResult(ResultHierarchy hier, Result result) {
Database db = ResultUtil.findDatabase(hier);
// Prepare
SetDBIDs positiveids = DBIDUtil.ensureSet(DatabaseUtil.getObjectsByLabelMatch(db, positiveClassName));
if (positiveids.size() == 0) {
LOG.warning("Computing a ROC curve failed - no objects matched.");
return;
}
List<OutlierResult> oresults = OutlierResult.getOutlierResults(result);
List<OrderingResult> orderings = ResultUtil.getOrderingResults(result);
// Outlier results are the main use case.
for (OutlierResult o : oresults) {
DBIDs sorted = o.getOrdering().order(o.getOrdering().getDBIDs());
db.getHierarchy().add(o, computePrecisionResult(o.getScores().size(), positiveids, sorted));
// Process them only once.
orderings.remove(o.getOrdering());
}
// otherwise apply an ordering to the database IDs.
for (OrderingResult or : orderings) {
DBIDs sorted = or.order(or.getDBIDs());
db.getHierarchy().add(or, computePrecisionResult(or.getDBIDs().size(), positiveids, sorted));
}
}
use of de.lmu.ifi.dbs.elki.database.ids.SetDBIDs in project elki by elki-project.
the class P3C method constructOneSignatures.
/**
* Construct the 1-signatures by merging adjacent dense bins.
*
* @param partitions Initial partitions.
* @param markers Markers for dense partitions.
* @return 1-signatures
*/
private ArrayList<Signature> constructOneSignatures(SetDBIDs[][] partitions, final long[][] markers) {
final int dim = partitions.length;
// Generate projected p-signature intervals.
ArrayList<Signature> signatures = new ArrayList<>();
for (int d = 0; d < dim; d++) {
final DBIDs[] parts = partitions[d];
if (parts == null) {
// Never mark any on constant dimensions.
continue;
}
final long[] marked = markers[d];
// Find sequences of 1s in marked.
for (int start = BitsUtil.nextSetBit(marked, 0); start >= 0; ) {
int end = BitsUtil.nextClearBit(marked, start + 1);
end = (end == -1) ? dim : end;
int[] signature = new int[dim << 1];
Arrays.fill(signature, -1);
signature[d << 1] = start;
// inclusive
signature[(d << 1) + 1] = end - 1;
HashSetModifiableDBIDs sids = unionDBIDs(parts, start, end);
if (LOG.isDebugging()) {
LOG.debug("1-signature: " + d + " " + start + "-" + (end - 1));
}
signatures.add(new Signature(signature, sids));
start = (end < dim) ? BitsUtil.nextSetBit(marked, end + 1) : -1;
}
}
return signatures;
}
Aggregations