Search in sources :

Example 6 with SetDBIDs

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());
    }
}
Also used : OrderingResult(de.lmu.ifi.dbs.elki.result.OrderingResult) Database(de.lmu.ifi.dbs.elki.database.Database) OutlierResult(de.lmu.ifi.dbs.elki.result.outlier.OutlierResult) SetDBIDs(de.lmu.ifi.dbs.elki.database.ids.SetDBIDs)

Example 7 with SetDBIDs

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);
    }
}
Also used : DBIDs(de.lmu.ifi.dbs.elki.database.ids.DBIDs) SetDBIDs(de.lmu.ifi.dbs.elki.database.ids.SetDBIDs) Database(de.lmu.ifi.dbs.elki.database.Database) OutlierResult(de.lmu.ifi.dbs.elki.result.outlier.OutlierResult) SetDBIDs(de.lmu.ifi.dbs.elki.database.ids.SetDBIDs)

Example 8 with SetDBIDs

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.");
    }
}
Also used : DBIDs(de.lmu.ifi.dbs.elki.database.ids.DBIDs) SetDBIDs(de.lmu.ifi.dbs.elki.database.ids.SetDBIDs) Database(de.lmu.ifi.dbs.elki.database.Database) OutlierResult(de.lmu.ifi.dbs.elki.result.outlier.OutlierResult) SetDBIDs(de.lmu.ifi.dbs.elki.database.ids.SetDBIDs)

Example 9 with SetDBIDs

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));
    }
}
Also used : OrderingResult(de.lmu.ifi.dbs.elki.result.OrderingResult) DBIDs(de.lmu.ifi.dbs.elki.database.ids.DBIDs) SetDBIDs(de.lmu.ifi.dbs.elki.database.ids.SetDBIDs) Database(de.lmu.ifi.dbs.elki.database.Database) OutlierResult(de.lmu.ifi.dbs.elki.result.outlier.OutlierResult) SetDBIDs(de.lmu.ifi.dbs.elki.database.ids.SetDBIDs)

Example 10 with SetDBIDs

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;
}
Also used : HashSetModifiableDBIDs(de.lmu.ifi.dbs.elki.database.ids.HashSetModifiableDBIDs) ArrayModifiableDBIDs(de.lmu.ifi.dbs.elki.database.ids.ArrayModifiableDBIDs) DBIDs(de.lmu.ifi.dbs.elki.database.ids.DBIDs) HashSetModifiableDBIDs(de.lmu.ifi.dbs.elki.database.ids.HashSetModifiableDBIDs) SetDBIDs(de.lmu.ifi.dbs.elki.database.ids.SetDBIDs) ModifiableDBIDs(de.lmu.ifi.dbs.elki.database.ids.ModifiableDBIDs) ArrayList(java.util.ArrayList)

Aggregations

SetDBIDs (de.lmu.ifi.dbs.elki.database.ids.SetDBIDs)11 DBIDs (de.lmu.ifi.dbs.elki.database.ids.DBIDs)6 Database (de.lmu.ifi.dbs.elki.database.Database)5 ArrayModifiableDBIDs (de.lmu.ifi.dbs.elki.database.ids.ArrayModifiableDBIDs)5 OutlierResult (de.lmu.ifi.dbs.elki.result.outlier.OutlierResult)5 HashSetModifiableDBIDs (de.lmu.ifi.dbs.elki.database.ids.HashSetModifiableDBIDs)4 ArrayList (java.util.ArrayList)3 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)2 KNNList (de.lmu.ifi.dbs.elki.database.ids.KNNList)2 ModifiableDBIDs (de.lmu.ifi.dbs.elki.database.ids.ModifiableDBIDs)2 StepProgress (de.lmu.ifi.dbs.elki.logging.progress.StepProgress)2 OrderingResult (de.lmu.ifi.dbs.elki.result.OrderingResult)2 MultivariateGaussianModel (de.lmu.ifi.dbs.elki.algorithm.clustering.em.MultivariateGaussianModel)1 Clustering (de.lmu.ifi.dbs.elki.data.Clustering)1 Subspace (de.lmu.ifi.dbs.elki.data.Subspace)1 SortDBIDsBySingleDimension (de.lmu.ifi.dbs.elki.data.VectorUtil.SortDBIDsBySingleDimension)1 SubspaceModel (de.lmu.ifi.dbs.elki.data.model.SubspaceModel)1 ArrayDBIDs (de.lmu.ifi.dbs.elki.database.ids.ArrayDBIDs)1 DBIDArrayIter (de.lmu.ifi.dbs.elki.database.ids.DBIDArrayIter)1 DoubleDBIDList (de.lmu.ifi.dbs.elki.database.ids.DoubleDBIDList)1