Search in sources :

Example 6 with ResultHierarchy

use of de.lmu.ifi.dbs.elki.result.ResultHierarchy 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

ResultHierarchy (de.lmu.ifi.dbs.elki.result.ResultHierarchy)6 Result (de.lmu.ifi.dbs.elki.result.Result)3 FiniteProgress (de.lmu.ifi.dbs.elki.logging.progress.FiniteProgress)2 BasicResult (de.lmu.ifi.dbs.elki.result.BasicResult)2 AbstractAlgorithm (de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm)1 Algorithm (de.lmu.ifi.dbs.elki.algorithm.Algorithm)1 Clustering (de.lmu.ifi.dbs.elki.data.Clustering)1 DoubleVector (de.lmu.ifi.dbs.elki.data.DoubleVector)1 NumberVector (de.lmu.ifi.dbs.elki.data.NumberVector)1 Database (de.lmu.ifi.dbs.elki.database.Database)1 ProxyDatabase (de.lmu.ifi.dbs.elki.database.ProxyDatabase)1 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)1 DBIDRange (de.lmu.ifi.dbs.elki.database.ids.DBIDRange)1 DBIDs (de.lmu.ifi.dbs.elki.database.ids.DBIDs)1 MaterializedRelation (de.lmu.ifi.dbs.elki.database.relation.MaterializedRelation)1 Relation (de.lmu.ifi.dbs.elki.database.relation.Relation)1 OutlierROCCurve (de.lmu.ifi.dbs.elki.evaluation.outlier.OutlierROCCurve)1 DecreasingVectorIter (de.lmu.ifi.dbs.elki.evaluation.scores.adapter.DecreasingVectorIter)1 VectorNonZero (de.lmu.ifi.dbs.elki.evaluation.scores.adapter.VectorNonZero)1 SimilarityMatrix (de.lmu.ifi.dbs.elki.evaluation.similaritymatrix.ComputeSimilarityMatrixImage.SimilarityMatrix)1