use of de.lmu.ifi.dbs.elki.utilities.ELKIBuilder in project elki by elki-project.
the class SingleAssignmentKMeansTest method testSingleAssignmentKMeans.
/**
* Run KMeans with fixed parameters and compare the result to a golden
* standard.
*/
@Test
public void testSingleAssignmentKMeans() {
Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d-no-noise.ascii", 1000);
Clustering<?> result = //
new ELKIBuilder<SingleAssignmentKMeans<DoubleVector>>(SingleAssignmentKMeans.class).with(KMeans.K_ID, //
5).with(KMeans.SEED_ID, //
7).build().run(db);
// Unsurprisingly, these results are much worse than normal k-means
testFMeasure(db, result, 0.702733122);
testClusterSizes(result, new int[] { 64, 95, 202, 306, 333 });
}
use of de.lmu.ifi.dbs.elki.utilities.ELKIBuilder in project elki by elki-project.
the class FarthestPointsInitialMeansTest method testFarthestPointsInitialMedoids.
/**
* Run CLARA with fixed parameters and compare the result to a golden
* standard.
*/
@Test
public void testFarthestPointsInitialMedoids() {
Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d-no-noise.ascii", 1000);
Clustering<?> result = //
new ELKIBuilder<CLARA<DoubleVector>>(CLARA.class).with(KMeans.K_ID, //
5).with(KMeans.SEED_ID, //
3).with(KMeans.INIT_ID, //
FarthestPointsInitialMeans.class).with(KMeans.MAXITER_ID, //
1).with(CLARA.Parameterizer.SAMPLESIZE_ID, //
10).with(CLARA.Parameterizer.RANDOM_ID, //
0).build().run(db);
testFMeasure(db, result, 0.8832692);
testClusterSizes(result, new int[] { 128, 200, 200, 201, 271 });
}
use of de.lmu.ifi.dbs.elki.utilities.ELKIBuilder in project elki by elki-project.
the class AbstractOutlierAlgorithmTest method testAUC.
/**
* Test the AUC value for an outlier result.
*
* @param db Database
* @param positive Positive class name
* @param result Outlier result to process
* @param expected Expected AUC value
*/
protected void testAUC(Database db, String positive, OutlierResult result, double expected) {
OutlierROCCurve rocCurve = //
new ELKIBuilder<>(OutlierROCCurve.class).with(OutlierROCCurve.Parameterizer.POSITIVE_CLASS_NAME_ID, positive).build();
// Ensure the result has been added to the hierarchy:
ResultHierarchy hier = db.getHierarchy();
if (hier.numParents(result) < 1) {
hier.add(db, result);
}
// Compute ROC and AUC:
rocCurve.processNewResult(hier, result);
// Find the ROC results
Collection<OutlierROCCurve.ROCResult> rocs = ResultUtil.filterResults(hier, result, OutlierROCCurve.ROCResult.class);
assertTrue("No ROC result found.", !rocs.isEmpty());
double auc = rocs.iterator().next().getAUC();
assertFalse("More than one ROC result found.", rocs.size() > 1);
assertEquals("ROC value does not match.", expected, auc, 0.0001);
}
use of de.lmu.ifi.dbs.elki.utilities.ELKIBuilder in project elki by elki-project.
the class GaussianUniformMixtureTest method testGaussianUniformMixture.
@Test
public void testGaussianUniformMixture() {
Database db = makeSimpleDatabase(UNITTEST + "outlier-fire.ascii", 1025);
OutlierResult result = new ELKIBuilder<GaussianUniformMixture<DoubleVector>>(GaussianUniformMixture.class).build().run(db);
testSingleScore(result, 1025, -20.27211494);
testAUC(db, "Noise", result, 0.97251282);
}
use of de.lmu.ifi.dbs.elki.utilities.ELKIBuilder in project elki by elki-project.
the class DBOutlierDetectionTest method testDBOutlierDetection.
@Test
public void testDBOutlierDetection() {
Database db = makeSimpleDatabase(UNITTEST + "outlier-fire.ascii", 1025);
OutlierResult result = //
new ELKIBuilder<DBOutlierDetection<DoubleVector>>(DBOutlierDetection.class).with(DBOutlierDetection.Parameterizer.D_ID, //
0.175).with(DBOutlierDetection.Parameterizer.P_ID, //
0.98).build().run(db);
testSingleScore(result, 1025, 0.0);
testAUC(db, "Noise", result, 0.97487179);
}
Aggregations