Search in sources :

Example 1 with DimensionModel

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

the class COPACTest method testCOPACResults.

/**
 * Run COPAC with fixed parameters and compare the result to a golden
 * standard.
 */
@Test
public void testCOPACResults() {
    Database db = makeSimpleDatabase(UNITTEST + "correlation-hierarchy.csv", 450);
    // these parameters are not picked too well - room for improvement.
    Clustering<DimensionModel> result = // 
    new ELKIBuilder<COPAC<DoubleVector>>(COPAC.class).with(DBSCAN.Parameterizer.EPSILON_ID, // 
    0.02).with(DBSCAN.Parameterizer.MINPTS_ID, // 
    50).with(COPAC.Parameterizer.K_ID, // 
    15).build().run(db);
    testFMeasure(db, result, 0.8484056);
    testClusterSizes(result, new int[] { 54, 196, 200 });
}
Also used : DimensionModel(de.lmu.ifi.dbs.elki.data.model.DimensionModel) Database(de.lmu.ifi.dbs.elki.database.Database) Test(org.junit.Test) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest)

Example 2 with DimensionModel

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

the class COPAC method run.

/**
 * Run the COPAC algorithm.
 *
 * @param database Database
 * @param relation Vector field relation
 * @return COPAC clustering
 */
public Clustering<DimensionModel> run(Database database, Relation<V> relation) {
    COPACNeighborPredicate.Instance npred = new COPACNeighborPredicate<V>(settings).instantiate(database, relation);
    CorePredicate.Instance<DBIDs> cpred = new MinPtsCorePredicate(settings.minpts).instantiate(database);
    Clustering<Model> dclusters = new GeneralizedDBSCAN.Instance<>(npred, cpred, false).run();
    // Re-wrap the detected clusters for COPAC:
    Clustering<DimensionModel> result = new Clustering<>("COPAC clustering", "copac-clustering");
    // Generalized DBSCAN clusterings will be flat.
    for (It<Cluster<Model>> iter = dclusters.iterToplevelClusters(); iter.valid(); iter.advance()) {
        Cluster<Model> clus = iter.get();
        if (clus.size() > 0) {
            int dim = npred.dimensionality(clus.getIDs().iter());
            DimensionModel model = new DimensionModel(dim);
            result.addToplevelCluster(new Cluster<>(clus.getIDs(), model));
        }
    }
    return result;
}
Also used : MinPtsCorePredicate(de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.MinPtsCorePredicate) CorePredicate(de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.CorePredicate) DimensionModel(de.lmu.ifi.dbs.elki.data.model.DimensionModel) DBIDs(de.lmu.ifi.dbs.elki.database.ids.DBIDs) Cluster(de.lmu.ifi.dbs.elki.data.Cluster) MinPtsCorePredicate(de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.MinPtsCorePredicate) COPACNeighborPredicate(de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.COPACNeighborPredicate) Clustering(de.lmu.ifi.dbs.elki.data.Clustering) DimensionModel(de.lmu.ifi.dbs.elki.data.model.DimensionModel) Model(de.lmu.ifi.dbs.elki.data.model.Model) GeneralizedDBSCAN(de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.GeneralizedDBSCAN)

Example 3 with DimensionModel

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

the class COPACTest method testCOPACOverlap.

/**
 * Run COPAC with fixed parameters and compare the result to a golden
 * standard.
 */
@Test
public void testCOPACOverlap() {
    Database db = makeSimpleDatabase(UNITTEST + "correlation-overlap-3-5d.ascii", 650);
    Clustering<DimensionModel> result = // 
    new ELKIBuilder<COPAC<DoubleVector>>(COPAC.class).with(DBSCAN.Parameterizer.EPSILON_ID, // 
    0.5).with(DBSCAN.Parameterizer.MINPTS_ID, // 
    20).with(COPAC.Parameterizer.K_ID, // 
    45).with(PCARunner.Parameterizer.PCA_COVARIANCE_MATRIX, // 
    WeightedCovarianceMatrixBuilder.class).with(WeightedCovarianceMatrixBuilder.Parameterizer.WEIGHT_ID, // 
    ErfcWeight.class).with(EigenPairFilter.PCA_EIGENPAIR_FILTER, // 
    PercentageEigenPairFilter.class).with(PercentageEigenPairFilter.Parameterizer.ALPHA_ID, // 
    0.8).build().run(db);
    testFMeasure(db, result, 0.86505092);
    testClusterSizes(result, new int[] { 32, 172, 197, 249 });
}
Also used : PercentageEigenPairFilter(de.lmu.ifi.dbs.elki.math.linearalgebra.pca.filter.PercentageEigenPairFilter) DimensionModel(de.lmu.ifi.dbs.elki.data.model.DimensionModel) Database(de.lmu.ifi.dbs.elki.database.Database) WeightedCovarianceMatrixBuilder(de.lmu.ifi.dbs.elki.math.linearalgebra.pca.WeightedCovarianceMatrixBuilder) Test(org.junit.Test) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest)

Aggregations

DimensionModel (de.lmu.ifi.dbs.elki.data.model.DimensionModel)3 AbstractClusterAlgorithmTest (de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest)2 Database (de.lmu.ifi.dbs.elki.database.Database)2 Test (org.junit.Test)2 COPACNeighborPredicate (de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.COPACNeighborPredicate)1 CorePredicate (de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.CorePredicate)1 GeneralizedDBSCAN (de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.GeneralizedDBSCAN)1 MinPtsCorePredicate (de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.MinPtsCorePredicate)1 Cluster (de.lmu.ifi.dbs.elki.data.Cluster)1 Clustering (de.lmu.ifi.dbs.elki.data.Clustering)1 Model (de.lmu.ifi.dbs.elki.data.model.Model)1 DBIDs (de.lmu.ifi.dbs.elki.database.ids.DBIDs)1 WeightedCovarianceMatrixBuilder (de.lmu.ifi.dbs.elki.math.linearalgebra.pca.WeightedCovarianceMatrixBuilder)1 PercentageEigenPairFilter (de.lmu.ifi.dbs.elki.math.linearalgebra.pca.filter.PercentageEigenPairFilter)1