Search in sources :

Example 11 with DBIDRef

use of de.lmu.ifi.dbs.elki.database.ids.DBIDRef in project elki by elki-project.

the class AbstractOutlierAlgorithmTest method testSingleScore.

/**
 * Test the outlier score of a single object.
 *
 * @param result Result object to use
 * @param id Object ID
 * @param expected expected value
 */
protected void testSingleScore(OutlierResult result, int id, double expected) {
    assertNotNull("No outlier result", result);
    assertNotNull("No score result.", result.getScores());
    DBIDs ids = result.getScores().getDBIDs();
    assertTrue("IDs must be array-based", ids instanceof ArrayDBIDs);
    // Translate offset. We used to use 1-indexed
    DBIDRef dbid = ((ArrayDBIDs) ids).iter().seek(id - 1);
    assertNotNull("No result for ID " + id, result.getScores().doubleValue(dbid));
    double actual = result.getScores().doubleValue(dbid);
    assertEquals("Outlier score of object " + id + " doesn't match.", expected, actual, 0.0001);
}
Also used : DBIDRef(de.lmu.ifi.dbs.elki.database.ids.DBIDRef) ArrayDBIDs(de.lmu.ifi.dbs.elki.database.ids.ArrayDBIDs) DBIDs(de.lmu.ifi.dbs.elki.database.ids.DBIDs) ArrayDBIDs(de.lmu.ifi.dbs.elki.database.ids.ArrayDBIDs)

Aggregations

DBIDRef (de.lmu.ifi.dbs.elki.database.ids.DBIDRef)11 ArrayModifiableDBIDs (de.lmu.ifi.dbs.elki.database.ids.ArrayModifiableDBIDs)8 WritableDoubleDataStore (de.lmu.ifi.dbs.elki.database.datastore.WritableDoubleDataStore)6 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)6 DBIDVar (de.lmu.ifi.dbs.elki.database.ids.DBIDVar)5 DBIDs (de.lmu.ifi.dbs.elki.database.ids.DBIDs)4 DBIDArrayIter (de.lmu.ifi.dbs.elki.database.ids.DBIDArrayIter)3 Relation (de.lmu.ifi.dbs.elki.database.relation.Relation)3 ModifiableDBIDs (de.lmu.ifi.dbs.elki.database.ids.ModifiableDBIDs)2 IntegerComparator (de.lmu.ifi.dbs.elki.utilities.datastructures.arrays.IntegerComparator)2 ArrayList (java.util.ArrayList)2 Comparator (java.util.Comparator)2 Random (java.util.Random)2 NumberVector (de.lmu.ifi.dbs.elki.data.NumberVector)1 ArrayDBIDs (de.lmu.ifi.dbs.elki.database.ids.ArrayDBIDs)1 DBIDMIter (de.lmu.ifi.dbs.elki.database.ids.DBIDMIter)1 AbortException (de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException)1