Search in sources :

Example 66 with Clustering

use of de.lmu.ifi.dbs.elki.data.Clustering in project elki by elki-project.

the class EvaluateSquaredErrors method processNewResult.

@Override
public void processNewResult(ResultHierarchy hier, Result result) {
    List<Clustering<?>> crs = Clustering.getClusteringResults(result);
    if (crs.isEmpty()) {
        return;
    }
    Database db = ResultUtil.findDatabase(hier);
    Relation<NumberVector> rel = db.getRelation(distance.getInputTypeRestriction());
    for (Clustering<?> c : crs) {
        evaluateClustering(db, rel, c);
    }
}
Also used : NumberVector(de.lmu.ifi.dbs.elki.data.NumberVector) Database(de.lmu.ifi.dbs.elki.database.Database) Clustering(de.lmu.ifi.dbs.elki.data.Clustering)

Example 67 with Clustering

use of de.lmu.ifi.dbs.elki.data.Clustering in project elki by elki-project.

the class EvaluateClustering method processNewResult.

@Override
public void processNewResult(ResultHierarchy hier, Result newResult) {
    // We may just have added this result.
    if (newResult instanceof Clustering && isReferenceResult((Clustering<?>) newResult)) {
        return;
    }
    Database db = ResultUtil.findDatabase(hier);
    List<Clustering<?>> crs = Clustering.getClusteringResults(newResult);
    if (crs == null || crs.isEmpty()) {
        return;
    }
    // Compute the reference clustering
    Clustering<?> refc = null;
    // Try to find an existing reference clustering (globally)
    {
        Collection<Clustering<?>> cs = ResultUtil.filterResults(hier, db, Clustering.class);
        for (Clustering<?> test : cs) {
            if (isReferenceResult(test)) {
                refc = test;
                break;
            }
        }
    }
    // Try to find an existing reference clustering (locally)
    if (refc == null) {
        Collection<Clustering<?>> cs = ResultUtil.filterResults(hier, newResult, Clustering.class);
        for (Clustering<?> test : cs) {
            if (isReferenceResult(test)) {
                refc = test;
                break;
            }
        }
    }
    if (refc == null) {
        LOG.debug("Generating a new reference clustering.");
        Result refres = referencealg.run(db);
        List<Clustering<?>> refcrs = Clustering.getClusteringResults(refres);
        if (refcrs.isEmpty()) {
            LOG.warning("Reference algorithm did not return a clustering result!");
            return;
        }
        if (refcrs.size() > 1) {
            LOG.warning("Reference algorithm returned more than one result!");
        }
        refc = refcrs.get(0);
    } else {
        LOG.debug("Using existing clustering: " + refc.getLongName() + " " + refc.getShortName());
    }
    for (Clustering<?> c : crs) {
        if (c == refc) {
            continue;
        }
        evaluteResult(db, c, refc);
    }
}
Also used : Database(de.lmu.ifi.dbs.elki.database.Database) Collection(java.util.Collection) ByLabelOrAllInOneClustering(de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelOrAllInOneClustering) Clustering(de.lmu.ifi.dbs.elki.data.Clustering) Result(de.lmu.ifi.dbs.elki.result.Result) EvaluationResult(de.lmu.ifi.dbs.elki.result.EvaluationResult)

Example 68 with Clustering

use of de.lmu.ifi.dbs.elki.data.Clustering in project elki by elki-project.

the class OpenGL3DParallelCoordinates method getStylePolicy.

/**
 * Hack: Get/Create the style result.
 *
 * @return Style result
 */
public StylingPolicy getStylePolicy(ResultHierarchy hier, StyleLibrary stylelib) {
    Database db = ResultUtil.findDatabase(hier);
    AutomaticEvaluation.ensureClusteringResult(db, db);
    List<Clustering<? extends Model>> clusterings = Clustering.getClusteringResults(db);
    if (clusterings.size() > 0) {
        return new ClusterStylingPolicy(clusterings.get(0), stylelib);
    } else {
        throw new AbortException("No clustering result generated?!?");
    }
}
Also used : Database(de.lmu.ifi.dbs.elki.database.Database) Model(de.lmu.ifi.dbs.elki.data.model.Model) Clustering(de.lmu.ifi.dbs.elki.data.Clustering) ClusterStylingPolicy(de.lmu.ifi.dbs.elki.visualization.style.ClusterStylingPolicy) AbortException(de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException)

Aggregations

Clustering (de.lmu.ifi.dbs.elki.data.Clustering)68 ModifiableDBIDs (de.lmu.ifi.dbs.elki.database.ids.ModifiableDBIDs)32 ArrayList (java.util.ArrayList)27 DBIDs (de.lmu.ifi.dbs.elki.database.ids.DBIDs)23 Cluster (de.lmu.ifi.dbs.elki.data.Cluster)21 Model (de.lmu.ifi.dbs.elki.data.model.Model)21 IndefiniteProgress (de.lmu.ifi.dbs.elki.logging.progress.IndefiniteProgress)20 WritableIntegerDataStore (de.lmu.ifi.dbs.elki.database.datastore.WritableIntegerDataStore)16 FiniteProgress (de.lmu.ifi.dbs.elki.logging.progress.FiniteProgress)16 Database (de.lmu.ifi.dbs.elki.database.Database)14 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)14 LongStatistic (de.lmu.ifi.dbs.elki.logging.statistics.LongStatistic)14 StringStatistic (de.lmu.ifi.dbs.elki.logging.statistics.StringStatistic)14 DoubleStatistic (de.lmu.ifi.dbs.elki.logging.statistics.DoubleStatistic)13 ClusterModel (de.lmu.ifi.dbs.elki.data.model.ClusterModel)12 KMeansModel (de.lmu.ifi.dbs.elki.data.model.KMeansModel)12 ArrayModifiableDBIDs (de.lmu.ifi.dbs.elki.database.ids.ArrayModifiableDBIDs)9 AbortException (de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException)8 ArrayDBIDs (de.lmu.ifi.dbs.elki.database.ids.ArrayDBIDs)6 MedoidModel (de.lmu.ifi.dbs.elki.data.model.MedoidModel)5