Search in sources :

Example 11 with Result

use of de.lmu.ifi.dbs.elki.result.Result in project elki by elki-project.

the class AlgorithmStep method runAlgorithms.

/**
 * Run algorithms.
 *
 * @param database Database
 * @return Algorithm result
 */
public Result runAlgorithms(Database database) {
    ResultHierarchy hier = database.getHierarchy();
    if (LOG.isStatistics()) {
        boolean first = true;
        for (It<Index> it = hier.iterDescendants(database).filter(Index.class); it.valid(); it.advance()) {
            if (first) {
                LOG.statistics("Index statistics before running algorithms:");
                first = false;
            }
            it.get().logStatistics();
        }
    }
    stepresult = new BasicResult("Algorithm Step", "algorithm-step");
    for (Algorithm algorithm : algorithms) {
        Thread.currentThread().setName(algorithm.toString());
        Duration duration = LOG.isStatistics() ? LOG.newDuration(algorithm.getClass().getName() + ".runtime").begin() : null;
        Result res = algorithm.run(database);
        if (duration != null) {
            LOG.statistics(duration.end());
        }
        if (LOG.isStatistics()) {
            boolean first = true;
            for (It<Index> it = hier.iterDescendants(database).filter(Index.class); it.valid(); it.advance()) {
                if (first) {
                    LOG.statistics("Index statistics after running algorithm " + algorithm.toString() + ":");
                    first = false;
                }
                it.get().logStatistics();
            }
        }
        if (res != null) {
            // Make sure the result is attached, but usually this is a noop:
            hier.add(database, res);
        }
    }
    return stepresult;
}
Also used : ResultHierarchy(de.lmu.ifi.dbs.elki.result.ResultHierarchy) BasicResult(de.lmu.ifi.dbs.elki.result.BasicResult) Index(de.lmu.ifi.dbs.elki.index.Index) Duration(de.lmu.ifi.dbs.elki.logging.statistics.Duration) Algorithm(de.lmu.ifi.dbs.elki.algorithm.Algorithm) AbstractAlgorithm(de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm) Result(de.lmu.ifi.dbs.elki.result.Result) BasicResult(de.lmu.ifi.dbs.elki.result.BasicResult)

Aggregations

Result (de.lmu.ifi.dbs.elki.result.Result)11 Database (de.lmu.ifi.dbs.elki.database.Database)6 AbstractClusterAlgorithmTest (de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest)3 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)3 ResultHierarchy (de.lmu.ifi.dbs.elki.result.ResultHierarchy)3 Test (org.junit.Test)3 AbstractAlgorithm (de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm)2 Algorithm (de.lmu.ifi.dbs.elki.algorithm.Algorithm)2 HDBSCANLinearMemory (de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.HDBSCANLinearMemory)2 Clustering (de.lmu.ifi.dbs.elki.data.Clustering)2 WritableDoubleDataStore (de.lmu.ifi.dbs.elki.database.datastore.WritableDoubleDataStore)2 DoubleRelation (de.lmu.ifi.dbs.elki.database.relation.DoubleRelation)2 MaterializedDoubleRelation (de.lmu.ifi.dbs.elki.database.relation.MaterializedDoubleRelation)2 FiniteProgress (de.lmu.ifi.dbs.elki.logging.progress.FiniteProgress)2 DoubleMinMax (de.lmu.ifi.dbs.elki.math.DoubleMinMax)2 BasicResult (de.lmu.ifi.dbs.elki.result.BasicResult)2 EvaluationResult (de.lmu.ifi.dbs.elki.result.EvaluationResult)2 BasicOutlierScoreMeta (de.lmu.ifi.dbs.elki.result.outlier.BasicOutlierScoreMeta)2 OutlierResult (de.lmu.ifi.dbs.elki.result.outlier.OutlierResult)2 OutlierScoreMeta (de.lmu.ifi.dbs.elki.result.outlier.OutlierScoreMeta)2