Search in sources :

Example 71 with DoubleVector

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

the class CASHTest method testCASHResults.

/**
 * Run CASH with fixed parameters and compare the result to a golden standard.
 */
@Test
public void testCASHResults() {
    Database db = makeSimpleDatabase(UNITTEST + "hierarchical-3d2d1d.csv", 600);
    Clustering<Model> result = // 
    new ELKIBuilder<CASH<DoubleVector>>(CASH.class).with(CASH.Parameterizer.JITTER_ID, // 
    0.7).with(CASH.Parameterizer.MINPTS_ID, // 
    50).with(CASH.Parameterizer.MAXLEVEL_ID, // 
    25).with(// 
    CASH.Parameterizer.ADJUST_ID).build().run(db);
    // with hierarchical pairs: 0.64102
    testFMeasure(db, result, 0.50074);
    testClusterSizes(result, new int[] { 18, 80, 252, 468 });
}
Also used : ELKIBuilder(de.lmu.ifi.dbs.elki.utilities.ELKIBuilder) Database(de.lmu.ifi.dbs.elki.database.Database) Model(de.lmu.ifi.dbs.elki.data.model.Model) DoubleVector(de.lmu.ifi.dbs.elki.data.DoubleVector) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest) Test(org.junit.Test)

Example 72 with DoubleVector

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

the class KMeansHamerly method recomputeSeperation.

/**
 * Recompute the separation of cluster means.
 *
 * @param means Means
 * @param sep Output array
 */
private void recomputeSeperation(double[][] means, double[] sep) {
    final int k = means.length;
    assert (sep.length == k);
    boolean issquared = distanceFunction.isSquared();
    Arrays.fill(sep, Double.POSITIVE_INFINITY);
    for (int i = 1; i < k; i++) {
        DoubleVector m1 = DoubleVector.wrap(means[i]);
        for (int j = 0; j < i; j++) {
            double d = distanceFunction.distance(m1, DoubleVector.wrap(means[j]));
            sep[i] = (d < sep[i]) ? d : sep[i];
            sep[j] = (d < sep[j]) ? d : sep[j];
        }
    }
    // We need half the Euclidean distance
    for (int i = 0; i < k; i++) {
        sep[i] = issquared ? FastMath.sqrt(sep[i]) : sep[i];
        sep[i] *= .5;
    }
}
Also used : DoubleVector(de.lmu.ifi.dbs.elki.data.DoubleVector)

Example 73 with DoubleVector

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

the class VisualizeGeodesicDistances method run.

@Override
public void run() {
    // Format: Latitude, Longitude
    // München:
    DoubleVector stap = DoubleVector.wrap(new double[] { 48.133333, 11.566667 });
    // New York:
    DoubleVector endp = DoubleVector.wrap(new double[] { 40.712778, -74.005833 });
    // Bavaria:
    ModifiableHyperBoundingBox bb = new ModifiableHyperBoundingBox(new double[] { 47.27011150, 8.97634970 }, new double[] { 50.56471420, 13.83963710 });
    // Bavaria slice on lat
    // bb = new ModifiableHyperBoundingBox(new double[] { 47.27011150, -80 }, //
    // new double[] { 50.56471420, 80 });
    // Bavaria slice on lon
    // bb = new ModifiableHyperBoundingBox(new double[] { -10, 8.97634970 }, //
    // new double[] { 50, 13.83963710 });
    BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    final double max = model.getEquatorialRadius() * Math.PI;
    // Red: left off-course, green: right off-course
    int red = 0xffff0000;
    int green = 0xff00ff00;
    FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("columns", width, LOG) : null;
    for (int x = 0; x < width; x++) {
        final double lon = x * 360. / width - 180.;
        for (int y = 0; y < height; y++) {
            final double lat = y * -180. / height + 90.;
            switch(mode) {
                case ATD:
                    {
                        final double atd = model.getEquatorialRadius() * SphereUtil.alongTrackDistanceDeg(stap.doubleValue(0), stap.doubleValue(1), endp.doubleValue(0), endp.doubleValue(1), lat, lon);
                        if (atd < 0) {
                            img.setRGB(x, y, colorMultiply(red, -atd / max, false));
                        } else {
                            img.setRGB(x, y, colorMultiply(green, atd / max, false));
                        }
                        break;
                    }
                case XTD:
                    {
                        final double ctd = model.getEquatorialRadius() * SphereUtil.crossTrackDistanceDeg(stap.doubleValue(0), stap.doubleValue(1), endp.doubleValue(0), endp.doubleValue(1), lat, lon);
                        if (ctd < 0) {
                            img.setRGB(x, y, colorMultiply(red, -ctd / max, false));
                        } else {
                            img.setRGB(x, y, colorMultiply(green, ctd / max, false));
                        }
                        break;
                    }
                case MINDIST:
                    {
                        final double dist = model.minDistDeg(lat, lon, bb.getMin(0), bb.getMin(1), bb.getMax(0), bb.getMax(1));
                        if (dist < 0) {
                            img.setRGB(x, y, colorMultiply(red, -dist / max, true));
                        } else {
                            img.setRGB(x, y, colorMultiply(green, dist / max, true));
                        }
                        break;
                    }
            }
        }
        LOG.incrementProcessed(prog);
    }
    LOG.ensureCompleted(prog);
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        LOG.exception(e);
    }
}
Also used : FiniteProgress(de.lmu.ifi.dbs.elki.logging.progress.FiniteProgress) DoubleVector(de.lmu.ifi.dbs.elki.data.DoubleVector) ModifiableHyperBoundingBox(de.lmu.ifi.dbs.elki.data.ModifiableHyperBoundingBox) IOException(java.io.IOException) BufferedImage(java.awt.image.BufferedImage)

Example 74 with DoubleVector

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

the class COPTest method testCOPRANSAC.

@Test
public void testCOPRANSAC() {
    Database db = makeSimpleDatabase(UNITTEST + "outlier-parabolic.ascii", 530);
    OutlierResult result = // 
    new ELKIBuilder<COP<DoubleVector>>(COP.class).with(COP.Parameterizer.K_ID, // 
    30).with(COP.Parameterizer.PCARUNNER_ID, // 
    AutotuningPCA.class).with(AutotuningPCA.Parameterizer.PCA_EIGENPAIR_FILTER, // 
    PercentageEigenPairFilter.class).with(AutotuningPCA.Parameterizer.PCA_COVARIANCE_MATRIX, // 
    RANSACCovarianceMatrixBuilder.class).with(RANSACCovarianceMatrixBuilder.Parameterizer.ITER_ID, // 
    25).with(RANSACCovarianceMatrixBuilder.Parameterizer.SEED_ID, // 
    0).build().run(db);
    testAUC(db, "Noise", result, 0.89526);
    testSingleScore(result, 416, 0.382879);
}
Also used : PercentageEigenPairFilter(de.lmu.ifi.dbs.elki.math.linearalgebra.pca.filter.PercentageEigenPairFilter) ELKIBuilder(de.lmu.ifi.dbs.elki.utilities.ELKIBuilder) Database(de.lmu.ifi.dbs.elki.database.Database) OutlierResult(de.lmu.ifi.dbs.elki.result.outlier.OutlierResult) DoubleVector(de.lmu.ifi.dbs.elki.data.DoubleVector) Test(org.junit.Test)

Example 75 with DoubleVector

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

the class ABODTest method testABOD.

@Test
public void testABOD() {
    Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960);
    OutlierResult result = new ELKIBuilder<ABOD<DoubleVector>>(ABOD.class).build().run(db);
    testAUC(db, "Noise", result, 0.9297962962962);
    testSingleScore(result, 945, 2.0897348547799E-5);
}
Also used : ELKIBuilder(de.lmu.ifi.dbs.elki.utilities.ELKIBuilder) Database(de.lmu.ifi.dbs.elki.database.Database) OutlierResult(de.lmu.ifi.dbs.elki.result.outlier.OutlierResult) DoubleVector(de.lmu.ifi.dbs.elki.data.DoubleVector) Test(org.junit.Test) AbstractOutlierAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.outlier.AbstractOutlierAlgorithmTest)

Aggregations

DoubleVector (de.lmu.ifi.dbs.elki.data.DoubleVector)147 Test (org.junit.Test)112 Database (de.lmu.ifi.dbs.elki.database.Database)85 ELKIBuilder (de.lmu.ifi.dbs.elki.utilities.ELKIBuilder)75 AbstractClusterAlgorithmTest (de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest)50 MultipleObjectsBundle (de.lmu.ifi.dbs.elki.datasource.bundle.MultipleObjectsBundle)26 AbstractDataSourceTest (de.lmu.ifi.dbs.elki.datasource.AbstractDataSourceTest)24 OutlierResult (de.lmu.ifi.dbs.elki.result.outlier.OutlierResult)22 AbstractOutlierAlgorithmTest (de.lmu.ifi.dbs.elki.algorithm.outlier.AbstractOutlierAlgorithmTest)16 ArrayList (java.util.ArrayList)14 DBIDs (de.lmu.ifi.dbs.elki.database.ids.DBIDs)12 NumberVector (de.lmu.ifi.dbs.elki.data.NumberVector)11 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)10 VectorFieldTypeInformation (de.lmu.ifi.dbs.elki.data.type.VectorFieldTypeInformation)9 ListParameterization (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization)9 Random (java.util.Random)9 AbstractSimpleAlgorithmTest (de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest)8 Model (de.lmu.ifi.dbs.elki.data.model.Model)8 LinearScanDistanceKNNQuery (de.lmu.ifi.dbs.elki.database.query.knn.LinearScanDistanceKNNQuery)8 MedoidModel (de.lmu.ifi.dbs.elki.data.model.MedoidModel)7