Search in sources :

Example 1 with NoSupportedDataTypeException

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

the class ByLabelOrAllInOneClustering method run.

@Override
public Clustering<Model> run(Database database) {
    // Prefer a true class label
    try {
        Relation<ClassLabel> relation = database.getRelation(TypeUtil.CLASSLABEL);
        return run(relation);
    } catch (NoSupportedDataTypeException e) {
    // Ignore.
    }
    try {
        Relation<ClassLabel> relation = database.getRelation(TypeUtil.GUESSED_LABEL);
        return run(relation);
    } catch (NoSupportedDataTypeException e) {
    // Ignore.
    }
    final DBIDs ids = database.getRelation(TypeUtil.ANY).getDBIDs();
    Clustering<Model> result = new Clustering<>("All-in-one trivial Clustering", "allinone-clustering");
    Cluster<Model> c = new Cluster<Model>(ids, ClusterModel.CLUSTER);
    result.addToplevelCluster(c);
    return result;
}
Also used : ClassLabel(de.lmu.ifi.dbs.elki.data.ClassLabel) NoSupportedDataTypeException(de.lmu.ifi.dbs.elki.data.type.NoSupportedDataTypeException) DBIDs(de.lmu.ifi.dbs.elki.database.ids.DBIDs) Model(de.lmu.ifi.dbs.elki.data.model.Model) ClusterModel(de.lmu.ifi.dbs.elki.data.model.ClusterModel) Cluster(de.lmu.ifi.dbs.elki.data.Cluster) Clustering(de.lmu.ifi.dbs.elki.data.Clustering)

Example 2 with NoSupportedDataTypeException

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

the class VisualizerContext method generateDefaultClustering.

/**
 * Generate a default (fallback) clustering.
 *
 * @return generated clustering
 */
private Clustering<Model> generateDefaultClustering() {
    final Database db = ResultUtil.findDatabase(hier);
    Clustering<Model> c = null;
    try {
        // Try to cluster by labels
        ByLabelHierarchicalClustering split = new ByLabelHierarchicalClustering();
        c = split.run(db);
    } catch (NoSupportedDataTypeException e) {
        // Put everything into one
        c = new TrivialAllInOne().run(db);
    }
    return c;
}
Also used : NoSupportedDataTypeException(de.lmu.ifi.dbs.elki.data.type.NoSupportedDataTypeException) Database(de.lmu.ifi.dbs.elki.database.Database) Model(de.lmu.ifi.dbs.elki.data.model.Model) TrivialAllInOne(de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.TrivialAllInOne) ByLabelHierarchicalClustering(de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelHierarchicalClustering)

Aggregations

Model (de.lmu.ifi.dbs.elki.data.model.Model)2 NoSupportedDataTypeException (de.lmu.ifi.dbs.elki.data.type.NoSupportedDataTypeException)2 ByLabelHierarchicalClustering (de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelHierarchicalClustering)1 TrivialAllInOne (de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.TrivialAllInOne)1 ClassLabel (de.lmu.ifi.dbs.elki.data.ClassLabel)1 Cluster (de.lmu.ifi.dbs.elki.data.Cluster)1 Clustering (de.lmu.ifi.dbs.elki.data.Clustering)1 ClusterModel (de.lmu.ifi.dbs.elki.data.model.ClusterModel)1 Database (de.lmu.ifi.dbs.elki.database.Database)1 DBIDs (de.lmu.ifi.dbs.elki.database.ids.DBIDs)1