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 });
}
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;
}
}
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);
}
}
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);
}
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);
}
Aggregations