diff options
Diffstat (limited to 'test/de/lmu/ifi/dbs/elki/algorithm')
45 files changed, 0 insertions, 4107 deletions
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/AbstractSimpleAlgorithmTest.java b/test/de/lmu/ifi/dbs/elki/algorithm/AbstractSimpleAlgorithmTest.java deleted file mode 100644 index 3e260e8e..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/AbstractSimpleAlgorithmTest.java +++ /dev/null @@ -1,242 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelClustering; -import de.lmu.ifi.dbs.elki.data.Cluster; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.model.Model; -import de.lmu.ifi.dbs.elki.data.type.TypeUtil; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.database.StaticArrayDatabase; -import de.lmu.ifi.dbs.elki.database.ids.DBID; -import de.lmu.ifi.dbs.elki.database.ids.DBIDUtil; -import de.lmu.ifi.dbs.elki.database.relation.Relation; -import de.lmu.ifi.dbs.elki.datasource.FileBasedDatabaseConnection; -import de.lmu.ifi.dbs.elki.datasource.filter.FixedDBIDsFilter; -import de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable; -import de.lmu.ifi.dbs.elki.evaluation.outlier.OutlierROCCurve; -import de.lmu.ifi.dbs.elki.logging.Logging; -import de.lmu.ifi.dbs.elki.result.Result; -import de.lmu.ifi.dbs.elki.result.ResultUtil; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Abstract base class useful for testing various algorithms. - * - * @author Erich Schubert - */ -public abstract class AbstractSimpleAlgorithmTest { - /** - * Base path for unit test files. - */ - public final static String UNITTEST = "data/testdata/unittests/"; - - /** - * Notice: this is okay for tests - don't use this for frequently used - * objects, use a static instance instead! - */ - protected Logging logger = Logging.getLogger(this.getClass()); - - /** - * Validate that parameterization succeeded: no parameters left, no - * parameterization errors. - * - * @param config Parameterization to test - */ - protected void testParameterizationOk(ListParameterization config) { - if (config.hasUnusedParameters()) { - fail("Unused parameters: " + config.getRemainingParameters()); - } - if (config.hasErrors()) { - config.logAndClearReportedErrors(); - fail("Parameterization errors."); - } - } - - /** - * Generate a simple DoubleVector database from a file. - * - * @param filename File to load - * @param expectedSize Expected size in records - * @param params Extra parameters - * @return Database - */ - protected <T> Database makeSimpleDatabase(String filename, int expectedSize, ListParameterization params, Class<?>[] filters) { - org.junit.Assert.assertTrue("Test data set not found: " + filename, (new File(filename)).exists()); - params.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, filename); - - List<Class<?>> filterlist = new ArrayList<>(); - filterlist.add(FixedDBIDsFilter.class); - if (filters != null) { - for (Class<?> filter : filters) { - filterlist.add(filter); - } - } - params.addParameter(FileBasedDatabaseConnection.Parameterizer.FILTERS_ID, filterlist); - params.addParameter(FixedDBIDsFilter.Parameterizer.IDSTART_ID, 1); - Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, params); - - testParameterizationOk(params); - - db.initialize(); - Relation<?> rel = db.getRelation(TypeUtil.ANY); - org.junit.Assert.assertEquals("Database size does not match.", expectedSize, rel.size()); - return db; - } - - /** - * Generate a simple DoubleVector database from a file. - * - * @param filename File to load - * @param expectedSize Expected size in records - * @return Database - */ - protected <T> Database makeSimpleDatabase(String filename, int expectedSize) { - return makeSimpleDatabase(filename, expectedSize, new ListParameterization(), null); - } - - /** - * Find a clustering result, fail if there is more than one or none. - * - * @param result Base result - * @return Clustering - */ - protected Clustering<?> findSingleClustering(Result result) { - List<Clustering<? extends Model>> clusterresults = ResultUtil.getClusteringResults(result); - assertTrue("No unique clustering found in result.", clusterresults.size() == 1); - Clustering<? extends Model> clustering = clusterresults.get(0); - return clustering; - } - - /** - * Test the clustering result by comparing the score with an expected value. - * - * @param database Database to test - * @param clustering Clustering result - * @param expected Expected score - */ - protected <O> void testFMeasure(Database database, Clustering<?> clustering, double expected) { - // Run by-label as reference - ByLabelClustering bylabel = new ByLabelClustering(); - Clustering<Model> rbl = bylabel.run(database); - - ClusterContingencyTable ct = new ClusterContingencyTable(true, false); - ct.process(clustering, rbl); - double score = ct.getPaircount().f1Measure(); - if (logger.isVerbose()) { - logger.verbose(this.getClass().getSimpleName() + " score: " + score + " expect: " + expected); - } - org.junit.Assert.assertEquals(this.getClass().getSimpleName() + ": Score does not match.", expected, score, 0.0001); - } - - /** - * Validate the cluster sizes with an expected result. - * - * @param clustering Clustering to test - * @param expected Expected cluster sizes - */ - protected void testClusterSizes(Clustering<?> clustering, int[] expected) { - List<Integer> sizes = new java.util.ArrayList<>(); - for (Cluster<?> cl : clustering.getAllClusters()) { - sizes.add(cl.size()); - } - // Sort both - Collections.sort(sizes); - Arrays.sort(expected); - // Report - // if(logger.isVerbose()) { - StringBuilder buf = new StringBuilder(); - buf.append("Cluster sizes: ["); - for (int i = 0; i < sizes.size(); i++) { - if (i > 0) { - buf.append(", "); - } - buf.append(sizes.get(i)); - } - buf.append("]"); - // } - // Test - org.junit.Assert.assertEquals("Number of clusters does not match expectations. " + buf.toString(), expected.length, sizes.size()); - for (int i = 0; i < expected.length; i++) { - org.junit.Assert.assertEquals("Cluster size does not match at position " + i + " in " + buf.toString(), expected[i], (int) sizes.get(i)); - } - } - - /** - * 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) { - ListParameterization params = new ListParameterization(); - params.addParameter(OutlierROCCurve.POSITIVE_CLASS_NAME_ID, positive); - OutlierROCCurve rocCurve = ClassGenericsUtil.parameterizeOrAbort(OutlierROCCurve.class, params); - - // Ensure the result has been added to the hierarchy: - if (db.getHierarchy().numParents(result) < 1) { - db.getHierarchy().add(db, result); - } - - // Compute ROC and AUC: - rocCurve.processNewResult(db, result); - // Find the ROC results - Collection<OutlierROCCurve.ROCResult> rocs = ResultUtil.filterResults(result, OutlierROCCurve.ROCResult.class); - org.junit.Assert.assertTrue("No ROC result found.", !rocs.isEmpty()); - double auc = rocs.iterator().next().getAUC(); - org.junit.Assert.assertFalse("More than one ROC result found.", rocs.size() > 1); - org.junit.Assert.assertEquals("ROC value does not match.", expected, auc, 0.0001); - } - - /** - * Test the outlier score of a single object. - * - * @param result Result object to use - * @param id Object ID - * @param expected expected value - */ - protected void testSingleScore(OutlierResult result, int id, double expected) { - org.junit.Assert.assertNotNull("No outlier result", result); - org.junit.Assert.assertNotNull("No score result.", result.getScores()); - final DBID dbid = DBIDUtil.importInteger(id); - org.junit.Assert.assertNotNull("No result for ID " + id, result.getScores().get(dbid)); - double actual = result.getScores().get(dbid); - org.junit.Assert.assertEquals("Outlier score of object " + id + " doesn't match.", expected, actual, 0.0001); - } -} diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/TestKNNJoin.java b/test/de/lmu/ifi/dbs/elki/algorithm/TestKNNJoin.java deleted file mode 100644 index 19509350..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/TestKNNJoin.java +++ /dev/null @@ -1,215 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.NumberVector; -import de.lmu.ifi.dbs.elki.data.type.TypeUtil; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.database.QueryUtil; -import de.lmu.ifi.dbs.elki.database.StaticArrayDatabase; -import de.lmu.ifi.dbs.elki.database.datastore.DataStore; -import de.lmu.ifi.dbs.elki.database.ids.DBIDIter; -import de.lmu.ifi.dbs.elki.database.ids.distance.KNNList; -import de.lmu.ifi.dbs.elki.database.query.distance.DistanceQuery; -import de.lmu.ifi.dbs.elki.database.query.knn.KNNQuery; -import de.lmu.ifi.dbs.elki.database.relation.Relation; -import de.lmu.ifi.dbs.elki.datasource.FileBasedDatabaseConnection; -import de.lmu.ifi.dbs.elki.datasource.filter.FixedDBIDsFilter; -import de.lmu.ifi.dbs.elki.distance.distancefunction.minkowski.EuclideanDistanceFunction; -import de.lmu.ifi.dbs.elki.distance.distancefunction.minkowski.ManhattanDistanceFunction; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.index.tree.spatial.SpatialEntry; -import de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.deliclu.DeLiCluTree; -import de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.deliclu.DeLiCluTreeFactory; -import de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.rstar.RStarTree; -import de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.rstar.RStarTreeFactory; -import de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.rstar.RStarTreeNode; -import de.lmu.ifi.dbs.elki.math.MeanVariance; -import de.lmu.ifi.dbs.elki.persistent.AbstractPageFileFactory; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -public class TestKNNJoin implements JUnit4Test { - // the following values depend on the data set used! - String dataset = "data/testdata/unittests/uebungsblatt-2d-mini.csv"; - - // size of the data set - int shoulds = 20; - - // mean number of 2NN - double mean2nnEuclid = 2.85; - - // variance - double var2nnEuclid = 0.87105; - - // mean number of 2NN - double mean2nnManhattan = 2.9; - - // variance - double var2nnManhattan = 0.83157894; - - @Test - public void testLinearScan() { - ListParameterization inputparams = new ListParameterization(); - inputparams.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, dataset); - List<Class<?>> filters = Arrays.asList(new Class<?>[] { FixedDBIDsFilter.class }); - inputparams.addParameter(FileBasedDatabaseConnection.Parameterizer.FILTERS_ID, filters); - inputparams.addParameter(FixedDBIDsFilter.Parameterizer.IDSTART_ID, 1); - - // get database - Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, inputparams); - inputparams.failOnErrors(); - - db.initialize(); - Relation<NumberVector<?>> relation = db.getRelation(TypeUtil.NUMBER_VECTOR_FIELD); - // verify data set size. - org.junit.Assert.assertEquals("Database size does not match.", shoulds, relation.size()); - - // Euclidean - { - DistanceQuery<NumberVector<?>, DoubleDistance> dq = db.getDistanceQuery(relation, EuclideanDistanceFunction.STATIC); - KNNQuery<NumberVector<?>, DoubleDistance> knnq = QueryUtil.getLinearScanKNNQuery(dq); - - MeanVariance meansize = new MeanVariance(); - for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { - KNNList<DoubleDistance> knnlist = knnq.getKNNForDBID(iditer, 2); - meansize.put(knnlist.size()); - } - org.junit.Assert.assertEquals("Euclidean mean 2NN", mean2nnEuclid, meansize.getMean(), 0.00001); - org.junit.Assert.assertEquals("Euclidean variance 2NN", var2nnEuclid, meansize.getSampleVariance(), 0.00001); - } - // Manhattan - { - DistanceQuery<NumberVector<?>, DoubleDistance> dq = db.getDistanceQuery(relation, ManhattanDistanceFunction.STATIC); - KNNQuery<NumberVector<?>, DoubleDistance> knnq = QueryUtil.getLinearScanKNNQuery(dq); - - MeanVariance meansize = new MeanVariance(); - for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { - KNNList<DoubleDistance> knnlist = knnq.getKNNForDBID(iditer, 2); - meansize.put(knnlist.size()); - } - org.junit.Assert.assertEquals("Manhattan mean 2NN", mean2nnManhattan, meansize.getMean(), 0.00001); - org.junit.Assert.assertEquals("Manhattan variance 2NN", var2nnManhattan, meansize.getSampleVariance(), 0.00001); - } - } - - /** - * Test {@link RStarTree} using a file based database connection. - * - * @throws ParameterException on errors. - */ - @Test - public void testKNNJoinRtreeMini() { - ListParameterization spatparams = new ListParameterization(); - spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, RStarTreeFactory.class); - spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 200); - - doKNNJoin(spatparams); - } - - /** - * Test {@link RStarTree} using a file based database connection. - * - * @throws ParameterException on errors. - */ - @Test - public void testKNNJoinRtreeMaxi() { - ListParameterization spatparams = new ListParameterization(); - spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, RStarTreeFactory.class); - spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 2000); - - doKNNJoin(spatparams); - } - - /** - * Test {@link DeLiCluTree} using a file based database connection. - * - * @throws ParameterException on errors. - */ - @Test - public void testKNNJoinDeLiCluTreeMini() { - ListParameterization spatparams = new ListParameterization(); - spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, DeLiCluTreeFactory.class); - spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 200); - - doKNNJoin(spatparams); - } - - /** - * Actual test routine. - * - * @param inputparams - * @throws ParameterException - */ - void doKNNJoin(ListParameterization inputparams) { - inputparams.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, dataset); - List<Class<?>> filters = Arrays.asList(new Class<?>[] { FixedDBIDsFilter.class }); - inputparams.addParameter(FileBasedDatabaseConnection.Parameterizer.FILTERS_ID, filters); - inputparams.addParameter(FixedDBIDsFilter.Parameterizer.IDSTART_ID, 1); - - // get database - Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, inputparams); - inputparams.failOnErrors(); - - db.initialize(); - Relation<NumberVector<?>> relation = db.getRelation(TypeUtil.NUMBER_VECTOR_FIELD); - // verify data set size. - org.junit.Assert.assertEquals("Database size does not match.", shoulds, relation.size()); - - // Euclidean - { - KNNJoin<DoubleVector, DoubleDistance, ?, ?> knnjoin = new KNNJoin<DoubleVector, DoubleDistance, RStarTreeNode, SpatialEntry>(EuclideanDistanceFunction.STATIC, 2); - DataStore<KNNList<DoubleDistance>> result = knnjoin.run(db); - - MeanVariance meansize = new MeanVariance(); - for(DBIDIter id = relation.getDBIDs().iter(); id.valid(); id.advance()) { - KNNList<DoubleDistance> knnlist = result.get(id); - meansize.put(knnlist.size()); - } - org.junit.Assert.assertEquals("Euclidean mean 2NN set size", mean2nnEuclid, meansize.getMean(), 0.00001); - org.junit.Assert.assertEquals("Euclidean variance 2NN", var2nnEuclid, meansize.getSampleVariance(), 0.00001); - } - // Manhattan - { - KNNJoin<DoubleVector, DoubleDistance, ?, ?> knnjoin = new KNNJoin<DoubleVector, DoubleDistance, RStarTreeNode, SpatialEntry>(ManhattanDistanceFunction.STATIC, 2); - DataStore<KNNList<DoubleDistance>> result = knnjoin.run(db); - - MeanVariance meansize = new MeanVariance(); - for(DBIDIter id = relation.getDBIDs().iter(); id.valid(); id.advance()) { - KNNList<DoubleDistance> knnlist = result.get(id); - meansize.put(knnlist.size()); - } - org.junit.Assert.assertEquals("Manhattan mean 2NN", mean2nnManhattan, meansize.getMean(), 0.00001); - org.junit.Assert.assertEquals("Manhattan variance 2NN", var2nnManhattan, meansize.getSampleVariance(), 0.00001); - } - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDBSCANResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDBSCANResults.java deleted file mode 100644 index 34dd2e3d..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDBSCANResults.java +++ /dev/null @@ -1,144 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.GeneralizedDBSCAN; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.Model; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Performs a full DBSCAN run, and compares the result with a clustering derived - * from the data set labels. This test ensures that DBSCAN performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Elke Achtert - * @author Erich Schubert - * @author Katharina Rausch - */ -public class TestDBSCANResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run DBSCAN with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testDBSCANResults() { - Database db = makeSimpleDatabase(UNITTEST + "3clusters-and-noise-2d.csv", 330); - - // setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0.04); - params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 20); - DBSCAN<DoubleVector, DoubleDistance> dbscan = ClassGenericsUtil.parameterizeOrAbort(DBSCAN.class, params); - testParameterizationOk(params); - - // run DBSCAN on database - Clustering<Model> result = dbscan.run(db); - - testFMeasure(db, result, 0.996413); - testClusterSizes(result, new int[] { 29, 50, 101, 150 }); - } - - /** - * Run DBSCAN with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testDBSCANOnSingleLinkDataset() { - Database db = makeSimpleDatabase(UNITTEST + "single-link-effect.ascii", 638); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 11.5); - params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 120); - DBSCAN<DoubleVector, DoubleDistance> dbscan = ClassGenericsUtil.parameterizeOrAbort(DBSCAN.class, params); - testParameterizationOk(params); - - // run DBSCAN on database - Clustering<Model> result = dbscan.run(db); - testFMeasure(db, result, 0.954382); - testClusterSizes(result, new int[] { 11, 200, 203, 224 }); - } - - /** - * Run DBSCAN with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testGDBSCANResults() { - Database db = makeSimpleDatabase(UNITTEST + "3clusters-and-noise-2d.csv", 330); - - // setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0.04); - params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 20); - GeneralizedDBSCAN dbscan = ClassGenericsUtil.parameterizeOrAbort(GeneralizedDBSCAN.class, params); - testParameterizationOk(params); - - // run DBSCAN on database - Clustering<Model> result = dbscan.run(db); - - testClusterSizes(result, new int[] { 29, 50, 101, 150 }); - testFMeasure(db, result, 0.996413); - } - - /** - * Run DBSCAN with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testGDBSCANOnSingleLinkDataset() { - Database db = makeSimpleDatabase(UNITTEST + "single-link-effect.ascii", 638); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 11.5); - params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 120); - GeneralizedDBSCAN dbscan = ClassGenericsUtil.parameterizeOrAbort(GeneralizedDBSCAN.class, params); - testParameterizationOk(params); - - // run DBSCAN on database - Clustering<Model> result = dbscan.run(db); - testClusterSizes(result, new int[] { 11, 200, 203, 224 }); - testFMeasure(db, result, 0.954382); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDeLiCluResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDeLiCluResults.java deleted file mode 100644 index b70c0f67..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDeLiCluResults.java +++ /dev/null @@ -1,90 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelClustering; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.model.Model; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.database.StaticArrayDatabase; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable; -import de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.deliclu.DeLiCluTreeFactory; -import de.lmu.ifi.dbs.elki.persistent.AbstractPageFileFactory; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Performs a full DeLiClu run, and compares the result with a clustering - * derived from the data set labels. This test ensures that DeLiClu's - * performance doesn't unexpectedly drop on this data set (and also ensures that - * the algorithms work, as a side effect). - * - * @author Katharina Rausch - * @author Erich Schubert - */ -public class TestDeLiCluResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run DeLiClu with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testDeLiCluResults() { - ListParameterization indexparams = new ListParameterization(); - // We need a special index for this algorithm: - indexparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, DeLiCluTreeFactory.class); - indexparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 1000); - Database db = makeSimpleDatabase(UNITTEST + "hierarchical-2d.ascii", 710, indexparams, null); - - // Setup actual algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(DeLiClu.MINPTS_ID, 18); - params.addParameter(OPTICSXi.XI_ID, 0.038); - params.addParameter(OPTICSXi.XIALG_ID, DeLiClu.class); - OPTICSXi<DoubleDistance> opticsxi = ClassGenericsUtil.parameterizeOrAbort(OPTICSXi.class, params); - testParameterizationOk(params); - - // run DeLiClu on database - Clustering<?> clustering = opticsxi.run(db); - - // Test F-Measure - ByLabelClustering bylabel = new ByLabelClustering(); - Clustering<Model> rbl = bylabel.run(db); - ClusterContingencyTable ct = new ClusterContingencyTable(true, false); - ct.process(clustering, rbl); - double score = ct.getPaircount().f1Measure(); - // We cannot test exactly - due to Hashing, DeLiClu sequence is not - // identical each time, the results will vary slightly. - assertEquals(this.getClass().getSimpleName() + ": Score does not match: " + score, score, 0.807415, 1E-5); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestEMResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestEMResults.java deleted file mode 100644 index 065307be..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestEMResults.java +++ /dev/null @@ -1,70 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.clustering.kmeans.KMeans; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.EMModel; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Performs a full EM run, and compares the result with a clustering derived - * from the data set labels. This test ensures that EM's performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Katharina Rausch - * @author Erich Schubert - */ -public class TestEMResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run EM with fixed parameters and compare the result to a golden standard. - * - * @throws ParameterException - */ - @Test - public void testEMResults() { - Database db = makeSimpleDatabase(UNITTEST + "hierarchical-2d.ascii", 710); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(KMeans.SEED_ID, 0); - params.addParameter(EM.Parameterizer.K_ID, 6); - EM<DoubleVector> em = ClassGenericsUtil.parameterizeOrAbort(EM.class, params); - testParameterizationOk(params); - - // run EM on database - Clustering<EMModel<DoubleVector>> result = em.run(db); - testFMeasure(db, result, 0.7551098); - testClusterSizes(result, new int[] { 50, 99, 102, 120, 141, 198 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestOPTICSResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestOPTICSResults.java deleted file mode 100644 index dde81a0f..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestOPTICSResults.java +++ /dev/null @@ -1,71 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Performs a full OPTICS run, and compares the result with a clustering derived - * from the data set labels. This test ensures that OPTICS's performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Katharina Rausch - * @author Erich Schubert - */ -public class TestOPTICSResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run OPTICS with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testOPTICSResults() { - Database db = makeSimpleDatabase(UNITTEST + "hierarchical-2d.ascii", 710); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(OPTICS.MINPTS_ID, 18); - params.addParameter(OPTICSXi.XI_ID, 0.038); - params.addParameter(OPTICSXi.XIALG_ID, OPTICS.class); - OPTICSXi<DoubleDistance> opticsxi = ClassGenericsUtil.parameterizeOrAbort(OPTICSXi.class, params); - testParameterizationOk(params); - - // run OPTICS on database - Clustering<?> clustering = opticsxi.run(db); - - testFMeasure(db, clustering, 0.874062); - testClusterSizes(clustering, new int[] { 109, 121, 210, 270 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestSNNClusteringResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestSNNClusteringResults.java deleted file mode 100644 index 302d5c0b..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestSNNClusteringResults.java +++ /dev/null @@ -1,72 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.Model; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.index.preprocessed.snn.SharedNearestNeighborPreprocessor; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Performs a full SNNClustering run, and compares the result with a clustering - * derived from the data set labels. This test ensures that SNNClustering's - * performance doesn't unexpectedly drop on this data set (and also ensures that - * the algorithms work, as a side effect). - * - * @author Katharina Rausch - * @author Erich Schubert - */ -public class TestSNNClusteringResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run SNNClustering with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testSNNClusteringResults() { - Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d.ascii", 1200); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(SNNClustering.EPSILON_ID, 77); - params.addParameter(SNNClustering.MINPTS_ID, 28); - params.addParameter(SharedNearestNeighborPreprocessor.Factory.NUMBER_OF_NEIGHBORS_ID, 100); - SNNClustering<DoubleVector> snn = ClassGenericsUtil.parameterizeOrAbort(SNNClustering.class, params); - testParameterizationOk(params); - - // run SNN on database - Clustering<Model> result = snn.run(db); - testFMeasure(db, result, 0.832371422); - testClusterSizes(result, new int[] { 73, 228, 213, 219, 231, 236 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestCASHResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestCASHResults.java deleted file mode 100644 index 62791b68..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestCASHResults.java +++ /dev/null @@ -1,96 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.correlation; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.Model; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Perform a full CASH run, and compare the result with a clustering derived - * from the data set labels. This test ensures that CASH performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Erich Schubert - * @author Katharina Rausch - */ -public class TestCASHResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run CASH with fixed parameters and compare the result to a golden standard. - */ - @Test - public void testCASHResults() { - // Input - Database db = makeSimpleDatabase(UNITTEST + "hierarchical-3d2d1d.csv", 600, new ListParameterization(), null); - - // CASH parameters - ListParameterization params = new ListParameterization(); - params.addParameter(CASH.JITTER_ID, 0.7); - params.addParameter(CASH.MINPTS_ID, 50); - params.addParameter(CASH.MAXLEVEL_ID, 25); - params.addFlag(CASH.ADJUST_ID); - - // setup algorithm - CASH<DoubleVector> cash = ClassGenericsUtil.parameterizeOrAbort(CASH.class, params); - testParameterizationOk(params); - - // run CASH on database - Clustering<Model> result = cash.run(db); - - testFMeasure(db, result, 0.490551); // with hierarchical pairs: 0.64102 - testClusterSizes(result, new int[] { 37, 71, 76, 442 }); - } - - /** - * Run CASH with fixed parameters and compare the result to a golden standard. - */ - @Test - public void testCASHEmbedded() { - // CASH input - Database db = makeSimpleDatabase(UNITTEST + "correlation-embedded-2-4d.ascii", 600, new ListParameterization(), null); - - // CASH parameters - ListParameterization params = new ListParameterization(); - params.addParameter(CASH.JITTER_ID, 0.7); - params.addParameter(CASH.MINPTS_ID, 160); - params.addParameter(CASH.MAXLEVEL_ID, 40); - - // setup algorithm - CASH<DoubleVector> cash = ClassGenericsUtil.parameterizeOrAbort(CASH.class, params); - testParameterizationOk(params); - - // run CASH on database - Clustering<Model> result = cash.run(db); - testFMeasure(db, result, 0.443246); - testClusterSizes(result, new int[] { 169, 196, 235 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestCOPACResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestCOPACResults.java deleted file mode 100644 index 94c59557..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestCOPACResults.java +++ /dev/null @@ -1,114 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.correlation; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.clustering.DBSCAN; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.Model; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.index.preprocessed.localpca.KNNQueryFilteredPCAIndex; -import de.lmu.ifi.dbs.elki.math.linearalgebra.pca.PCAFilteredRunner; -import de.lmu.ifi.dbs.elki.math.linearalgebra.pca.PCARunner; -import de.lmu.ifi.dbs.elki.math.linearalgebra.pca.PercentageEigenPairFilter; -import de.lmu.ifi.dbs.elki.math.linearalgebra.pca.WeightedCovarianceMatrixBuilder; -import de.lmu.ifi.dbs.elki.math.linearalgebra.pca.weightfunctions.ErfcWeight; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Perform a full COPAC run, and compare the result with a clustering derived - * from the data set labels. This test ensures that COPAC performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Erich Schubert - * @author Katharina Rausch - */ -public class TestCOPACResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run COPAC with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException on errors. - */ - @Test - public void testCOPACResults() { - Database db = makeSimpleDatabase(UNITTEST + "correlation-hierarchy.csv", 450); - - // these parameters are not picked too smartly - room for improvement. - ListParameterization params = new ListParameterization(); - params.addParameter(COPAC.PARTITION_ALGORITHM_ID, DBSCAN.class); - params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0.02); - params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 50); - params.addParameter(COPAC.PREPROCESSOR_ID, KNNQueryFilteredPCAIndex.Factory.class); - params.addParameter(KNNQueryFilteredPCAIndex.Factory.K_ID, 15); - - COPAC<DoubleVector, DoubleDistance> copac = ClassGenericsUtil.parameterizeOrAbort(COPAC.class, params); - testParameterizationOk(params); - - // run COPAC on database - Clustering<Model> result = copac.run(db); - - testFMeasure(db, result, 0.842521); - testClusterSizes(result, new int[] { 6, 16, 32, 196, 200 }); - } - - /** - * Run COPAC with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException on errors. - */ - @Test - public void testCOPACOverlap() { - Database db = makeSimpleDatabase(UNITTEST + "correlation-overlap-3-5d.ascii", 650); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(COPAC.PARTITION_ALGORITHM_ID, DBSCAN.class); - params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0.5); - params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 20); - params.addParameter(COPAC.PREPROCESSOR_ID, KNNQueryFilteredPCAIndex.Factory.class); - params.addParameter(KNNQueryFilteredPCAIndex.Factory.K_ID, 45); - // PCA - params.addParameter(PCARunner.PCA_COVARIANCE_MATRIX, WeightedCovarianceMatrixBuilder.class); - params.addParameter(WeightedCovarianceMatrixBuilder.WEIGHT_ID, ErfcWeight.class); - params.addParameter(PCAFilteredRunner.PCA_EIGENPAIR_FILTER, PercentageEigenPairFilter.class); - params.addParameter(PercentageEigenPairFilter.ALPHA_ID, 0.8); - - COPAC<DoubleVector, DoubleDistance> copac = ClassGenericsUtil.parameterizeOrAbort(COPAC.class, params); - testParameterizationOk(params); - - Clustering<Model> result = copac.run(db); - testFMeasure(db, result, 0.84687864); - testClusterSizes(result, new int[] { 1, 22, 22, 29, 34, 158, 182, 202 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestERiCResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestERiCResults.java deleted file mode 100644 index 76e8cca2..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestERiCResults.java +++ /dev/null @@ -1,130 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.correlation; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.clustering.DBSCAN; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.CorrelationModel; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancefunction.correlation.ERiCDistanceFunction; -import de.lmu.ifi.dbs.elki.index.preprocessed.localpca.KNNQueryFilteredPCAIndex; -import de.lmu.ifi.dbs.elki.math.linearalgebra.pca.PCAFilteredRunner; -import de.lmu.ifi.dbs.elki.math.linearalgebra.pca.PCARunner; -import de.lmu.ifi.dbs.elki.math.linearalgebra.pca.PercentageEigenPairFilter; -import de.lmu.ifi.dbs.elki.math.linearalgebra.pca.RelativeEigenPairFilter; -import de.lmu.ifi.dbs.elki.math.linearalgebra.pca.WeightedCovarianceMatrixBuilder; -import de.lmu.ifi.dbs.elki.math.linearalgebra.pca.weightfunctions.ErfcWeight; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Perform a full ERiC run, and compare the result with a clustering derived - * from the data set labels. This test ensures that ERiC performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Erich Schubert - * @author Katharina Rausch - */ -public class TestERiCResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run ERiC with fixed parameters and compare the result to a golden standard. - * - * @throws ParameterException on errors. - */ - @Test - public void testERiCResults() { - Database db = makeSimpleDatabase(UNITTEST + "hierarchical-3d2d1d.csv", 600); - - // ERiC - ListParameterization params = new ListParameterization(); - params.addParameter(COPAC.PARTITION_ALGORITHM_ID, DBSCAN.class); - params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 30); - params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0); - // ERiC Distance function in DBSCAN: - params.addParameter(COPAC.PARTITION_DISTANCE_ID, ERiCDistanceFunction.class); - params.addParameter(ERiCDistanceFunction.DELTA_ID, 0.20); - params.addParameter(ERiCDistanceFunction.TAU_ID, 0.04); - // Preprocessing via Local PCA: - params.addParameter(COPAC.PREPROCESSOR_ID, KNNQueryFilteredPCAIndex.Factory.class); - params.addParameter(KNNQueryFilteredPCAIndex.Factory.K_ID, 50); - // PCA - params.addParameter(PCARunner.PCA_COVARIANCE_MATRIX, WeightedCovarianceMatrixBuilder.class); - params.addParameter(WeightedCovarianceMatrixBuilder.WEIGHT_ID, ErfcWeight.class); - params.addParameter(PCAFilteredRunner.PCA_EIGENPAIR_FILTER, RelativeEigenPairFilter.class); - params.addParameter(RelativeEigenPairFilter.EIGENPAIR_FILTER_RALPHA, 1.60); - - ERiC<DoubleVector> eric = ClassGenericsUtil.parameterizeOrAbort(ERiC.class, params); - testParameterizationOk(params); - - // run ERiC on database - Clustering<CorrelationModel<DoubleVector>> result = eric.run(db); - - testFMeasure(db, result, 0.714207); // Hierarchical pairs scored: 0.9204825 - testClusterSizes(result, new int[] { 109, 184, 307 }); - } - - /** - * Run ERiC with fixed parameters and compare the result to a golden standard. - * - * @throws ParameterException on errors. - */ - @Test - public void testERiCOverlap() { - Database db = makeSimpleDatabase(UNITTEST + "correlation-overlap-3-5d.ascii", 650); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - // ERiC - params.addParameter(COPAC.PARTITION_ALGORITHM_ID, DBSCAN.class); - params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 15); - params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0); - // ERiC Distance function in DBSCAN: - params.addParameter(COPAC.PARTITION_DISTANCE_ID, ERiCDistanceFunction.class); - params.addParameter(ERiCDistanceFunction.DELTA_ID, 1.0); - params.addParameter(ERiCDistanceFunction.TAU_ID, 1.0); - // Preprocessing via Local PCA: - params.addParameter(COPAC.PREPROCESSOR_ID, KNNQueryFilteredPCAIndex.Factory.class); - params.addParameter(KNNQueryFilteredPCAIndex.Factory.K_ID, 45); - // PCA - params.addParameter(PCARunner.PCA_COVARIANCE_MATRIX, WeightedCovarianceMatrixBuilder.class); - params.addParameter(WeightedCovarianceMatrixBuilder.WEIGHT_ID, ErfcWeight.class); - params.addParameter(PCAFilteredRunner.PCA_EIGENPAIR_FILTER, PercentageEigenPairFilter.class); - params.addParameter(PercentageEigenPairFilter.ALPHA_ID, 0.6); - - ERiC<DoubleVector> eric = ClassGenericsUtil.parameterizeOrAbort(ERiC.class, params); - testParameterizationOk(params); - - // run ERiC on database - Clustering<CorrelationModel<DoubleVector>> result = eric.run(db); - testFMeasure(db, result, 0.831136946); - testClusterSizes(result, new int[] { 29, 189, 207, 225 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestFourCResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestFourCResults.java deleted file mode 100644 index 8604a5f0..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestFourCResults.java +++ /dev/null @@ -1,98 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.correlation; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractProjectedDBSCAN; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.Model; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Perform a full 4C run, and compare the result with a clustering derived from - * the data set labels. This test ensures that 4C performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Erich Schubert - * @author Katharina Rausch - */ -public class TestFourCResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run 4F with fixed parameters and compare the result to a golden standard. - * - * @throws ParameterException on errors. - */ - @Test - public void testFourCResults() { - Database db = makeSimpleDatabase(UNITTEST + "hierarchical-3d2d1d.csv", 600); - - // Setup 4C - ListParameterization params = new ListParameterization(); - params.addParameter(AbstractProjectedDBSCAN.EPSILON_ID, 0.30); - params.addParameter(AbstractProjectedDBSCAN.MINPTS_ID, 20); - params.addParameter(AbstractProjectedDBSCAN.LAMBDA_ID, 5); - - FourC<DoubleVector> fourc = ClassGenericsUtil.parameterizeOrAbort(FourC.class, params); - testParameterizationOk(params); - - // run 4C on database - Clustering<Model> result = fourc.run(db); - - testFMeasure(db, result, 0.498048); // Hierarchical pairs scored: 0.79467 - testClusterSizes(result, new int[] { 5, 595 }); - } - - /** - * Run ERiC with fixed parameters and compare the result to a golden standard. - * - * @throws ParameterException on errors. - */ - @Test - public void testFourCOverlap() { - Database db = makeSimpleDatabase(UNITTEST + "correlation-overlap-3-5d.ascii", 650); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - // 4C - params.addParameter(AbstractProjectedDBSCAN.EPSILON_ID, 1.2); - params.addParameter(AbstractProjectedDBSCAN.MINPTS_ID, 5); - params.addParameter(AbstractProjectedDBSCAN.LAMBDA_ID, 3); - - FourC<DoubleVector> fourc = ClassGenericsUtil.parameterizeOrAbort(FourC.class, params); - testParameterizationOk(params); - - // run 4C on database - Clustering<Model> result = fourc.run(db); - testFMeasure(db, result, 0.48305405); - testClusterSizes(result, new int[] { 65, 70, 515 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestORCLUSResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestORCLUSResults.java deleted file mode 100644 index 5cdb09c9..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestORCLUSResults.java +++ /dev/null @@ -1,98 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.correlation; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.Model; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Performs a full ORCLUS run, and compares the result with a clustering derived - * from the data set labels. This test ensures that ORCLUS performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Elke Achtert - * @author Katharina Rausch - */ -public class TestORCLUSResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run ORCLUS with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException on errors. - */ - @Test - public void testORCLUSResults() { - Database db = makeSimpleDatabase(UNITTEST + "correlation-hierarchy.csv", 450); - - ListParameterization params = new ListParameterization(); - params.addParameter(ORCLUS.Parameterizer.K_ID, 3); - params.addParameter(ORCLUS.Parameterizer.L_ID, 1); - params.addParameter(ORCLUS.Parameterizer.SEED_ID, 2); - - // setup algorithm - ORCLUS<DoubleVector> orclus = ClassGenericsUtil.parameterizeOrAbort(ORCLUS.class, params); - testParameterizationOk(params); - - // run ORCLUS on database - Clustering<Model> result = orclus.run(db); - - testFMeasure(db, result, 0.6361108); // Hierarchical pairs scored: 0.789113 - testClusterSizes(result, new int[] { 19, 33, 398 }); - } - - /** - * Run ORCLUS with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException on errors. - */ - @Test - public void testORCLUSSkewedDisjoint() { - Database db = makeSimpleDatabase(UNITTEST + "correlation-skewed-disjoint-3-5d.ascii", 601); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(ORCLUS.Parameterizer.K_ID, 3); - params.addParameter(ORCLUS.Parameterizer.L_ID, 4); - params.addParameter(ORCLUS.Parameterizer.SEED_ID, 9); - - ORCLUS<DoubleVector> orclus = ClassGenericsUtil.parameterizeOrAbort(ORCLUS.class, params); - testParameterizationOk(params); - - // run ORCLUS on database - Clustering<Model> result = orclus.run(db); - testFMeasure(db, result, 0.8687866); - testClusterSizes(result, new int[] { 170, 200, 231 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/TestNaiveAgglomerativeHierarchicalClustering.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/TestNaiveAgglomerativeHierarchicalClustering.java deleted file mode 100644 index 8ed18823..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/TestNaiveAgglomerativeHierarchicalClustering.java +++ /dev/null @@ -1,140 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.Result; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; -import de.lmu.ifi.dbs.elki.workflow.AlgorithmStep; - -/** - * Perform agglomerative hierarchical clustering, using the naive algorithm. - * - * @author Erich Schubert - */ -public class TestNaiveAgglomerativeHierarchicalClustering extends AbstractSimpleAlgorithmTest implements JUnit4Test { - // TODO: add more data sets. - - /** - * Run agglomerative hierarchical clustering with fixed parameters and compare - * the result to a golden standard. - */ - @Test - public void testSingleLink() { - Database db = makeSimpleDatabase(UNITTEST + "single-link-effect.ascii", 638); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(ExtractFlatClusteringFromHierarchy.Parameterizer.OUTPUTMODE_ID, ExtractFlatClusteringFromHierarchy.OutputMode.STRICT_PARTITIONS); - params.addParameter(ExtractFlatClusteringFromHierarchy.Parameterizer.MINCLUSTERS_ID, 3); - params.addParameter(AlgorithmStep.Parameterizer.ALGORITHM_ID, NaiveAgglomerativeHierarchicalClustering.class); - params.addParameter(NaiveAgglomerativeHierarchicalClustering.Parameterizer.LINKAGE_ID, SingleLinkageMethod.class); - ExtractFlatClusteringFromHierarchy<DoubleDistance> c = ClassGenericsUtil.parameterizeOrAbort(ExtractFlatClusteringFromHierarchy.class, params); - testParameterizationOk(params); - - // run clustering algorithm on database - Result result = c.run(db); - Clustering<?> clustering = findSingleClustering(result); - testFMeasure(db, clustering, 0.6829722); - testClusterSizes(clustering, new int[] { 9, 200, 429 }); - } - - /** - * Run agglomerative hierarchical clustering with fixed parameters and compare - * the result to a golden standard. - */ - @Test - public void testWard() { - Database db = makeSimpleDatabase(UNITTEST + "single-link-effect.ascii", 638); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(ExtractFlatClusteringFromHierarchy.Parameterizer.OUTPUTMODE_ID, ExtractFlatClusteringFromHierarchy.OutputMode.STRICT_PARTITIONS); - params.addParameter(ExtractFlatClusteringFromHierarchy.Parameterizer.MINCLUSTERS_ID, 3); - params.addParameter(AlgorithmStep.Parameterizer.ALGORITHM_ID, NaiveAgglomerativeHierarchicalClustering.class); - ExtractFlatClusteringFromHierarchy<DoubleDistance> c = ClassGenericsUtil.parameterizeOrAbort(ExtractFlatClusteringFromHierarchy.class, params); - testParameterizationOk(params); - - // run clustering algorithm on database - Result result = c.run(db); - Clustering<?> clustering = findSingleClustering(result); - testFMeasure(db, clustering, 0.93866265); - testClusterSizes(clustering, new int[] { 200, 211, 227 }); - } - - /** - * Run agglomerative hierarchical clustering with fixed parameters and compare - * the result to a golden standard. - */ - @Test - public void testGroupAverage() { - Database db = makeSimpleDatabase(UNITTEST + "single-link-effect.ascii", 638); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(ExtractFlatClusteringFromHierarchy.Parameterizer.OUTPUTMODE_ID, ExtractFlatClusteringFromHierarchy.OutputMode.STRICT_PARTITIONS); - params.addParameter(ExtractFlatClusteringFromHierarchy.Parameterizer.MINCLUSTERS_ID, 3); - params.addParameter(AlgorithmStep.Parameterizer.ALGORITHM_ID, NaiveAgglomerativeHierarchicalClustering.class); - params.addParameter(NaiveAgglomerativeHierarchicalClustering.Parameterizer.LINKAGE_ID, GroupAverageLinkageMethod.class); - ExtractFlatClusteringFromHierarchy<DoubleDistance> c = ClassGenericsUtil.parameterizeOrAbort(ExtractFlatClusteringFromHierarchy.class, params); - testParameterizationOk(params); - - // run clustering algorithm on database - Result result = c.run(db); - Clustering<?> clustering = findSingleClustering(result); - testFMeasure(db, clustering, 0.93866265); - testClusterSizes(clustering, new int[] { 200, 211, 227 }); - } - - /** - * Run agglomerative hierarchical clustering with fixed parameters and compare - * the result to a golden standard. - */ - @Test - public void testCompleteLink() { - Database db = makeSimpleDatabase(UNITTEST + "single-link-effect.ascii", 638); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(ExtractFlatClusteringFromHierarchy.Parameterizer.OUTPUTMODE_ID, ExtractFlatClusteringFromHierarchy.OutputMode.STRICT_PARTITIONS); - params.addParameter(ExtractFlatClusteringFromHierarchy.Parameterizer.MINCLUSTERS_ID, 3); - params.addParameter(AlgorithmStep.Parameterizer.ALGORITHM_ID, NaiveAgglomerativeHierarchicalClustering.class); - params.addParameter(NaiveAgglomerativeHierarchicalClustering.Parameterizer.LINKAGE_ID, CompleteLinkageMethod.class); - ExtractFlatClusteringFromHierarchy<DoubleDistance> c = ClassGenericsUtil.parameterizeOrAbort(ExtractFlatClusteringFromHierarchy.class, params); - testParameterizationOk(params); - - // run clustering algorithm on database - Result result = c.run(db); - Clustering<?> clustering = findSingleClustering(result); - testFMeasure(db, clustering, 0.938167802); - testClusterSizes(clustering, new int[] { 200, 217, 221 }); - } -} diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/TestSLINKResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/TestSLINKResults.java deleted file mode 100644 index 8b25cf9c..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/TestSLINKResults.java +++ /dev/null @@ -1,75 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.Result; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; -import de.lmu.ifi.dbs.elki.workflow.AlgorithmStep; - -/** - * Performs a full SLINK run, and compares the result with a clustering derived - * from the data set labels. This test ensures that SLINK's performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Katharina Rausch - * @author Erich Schubert - */ -public class TestSLINKResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - // TODO: add a test for a non-single-link dataset? - - /** - * Run SLINK with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testSLINKResults() { - Database db = makeSimpleDatabase(UNITTEST + "single-link-effect.ascii", 638); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(ExtractFlatClusteringFromHierarchy.Parameterizer.OUTPUTMODE_ID, ExtractFlatClusteringFromHierarchy.OutputMode.STRICT_PARTITIONS); - params.addParameter(ExtractFlatClusteringFromHierarchy.Parameterizer.MINCLUSTERS_ID, 3); - params.addParameter(AlgorithmStep.Parameterizer.ALGORITHM_ID, SLINK.class); - ExtractFlatClusteringFromHierarchy<DoubleDistance> slink = ClassGenericsUtil.parameterizeOrAbort(ExtractFlatClusteringFromHierarchy.class, params); - testParameterizationOk(params); - - // run SLINK on database - Result result = slink.run(db); - Clustering<?> clustering = findSingleClustering(result); - testFMeasure(db, clustering, 0.6829722); - testClusterSizes(clustering, new int[] { 9, 200, 429 }); - } -} diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansBisecting.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansBisecting.java deleted file mode 100644 index d678981d..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansBisecting.java +++ /dev/null @@ -1,90 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.kmeans; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2013 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.clustering.kmeans.quality.WithinClusterVarianceQualityMeasure; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.MeanModel; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the KMeansBisecting - * - * @author Stephan Baier - */ -public class TestKMeansBisecting extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run KMeansBisecting with fixed parameters and compare cluster size to - * expected value. - */ - @Test - public void testKMeansBisectingClusterSize() { - Database db = makeSimpleDatabase(UNITTEST + "bisecting-test.csv", 300); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(KMeans.K_ID, 3); - params.addParameter(BestOfMultipleKMeans.Parameterizer.TRIALS_ID, 5); - params.addParameter(BestOfMultipleKMeans.Parameterizer.KMEANS_ID, KMeansLloyd.class); - params.addParameter(BestOfMultipleKMeans.Parameterizer.QUALITYMEASURE_ID, WithinClusterVarianceQualityMeasure.class); - - KMeansBisecting<DoubleVector, DoubleDistance, MeanModel<DoubleVector>> kmeans = ClassGenericsUtil.parameterizeOrAbort(KMeansBisecting.class, params); - testParameterizationOk(params); - - // run KMedians on database - Clustering<MeanModel<DoubleVector>> result = kmeans.run(db); - testClusterSizes(result, new int[] { 103, 97, 100 }); - } - - /** - * Run KMeansBisecting with fixed parameters (k = 2) and compare f-measure to - * golden standard. - */ - @Test - public void testKMeansBisectingFMeasure() { - Database db = makeSimpleDatabase(UNITTEST + "bisecting-test.csv", 300); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(KMeans.K_ID, 2); - params.addParameter(BestOfMultipleKMeans.Parameterizer.TRIALS_ID, 5); - params.addParameter(BestOfMultipleKMeans.Parameterizer.KMEANS_ID, KMeansLloyd.class); - params.addParameter(BestOfMultipleKMeans.Parameterizer.QUALITYMEASURE_ID, WithinClusterVarianceQualityMeasure.class); - - KMeansBisecting<DoubleVector, DoubleDistance, MeanModel<DoubleVector>> kmeans = ClassGenericsUtil.parameterizeOrAbort(KMeansBisecting.class, params); - testParameterizationOk(params); - - // run KMedians on database - Clustering<MeanModel<DoubleVector>> result = kmeans.run(db); - testFMeasure(db, result, 0.7408); - } -} diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansQualityMeasure.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansQualityMeasure.java deleted file mode 100644 index 44603617..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansQualityMeasure.java +++ /dev/null @@ -1,110 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.kmeans; - -/* - This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2013 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.clustering.kmeans.quality.KMeansQualityMeasure; -import de.lmu.ifi.dbs.elki.algorithm.clustering.kmeans.quality.WithinClusterMeanDistanceQualityMeasure; -import de.lmu.ifi.dbs.elki.algorithm.clustering.kmeans.quality.WithinClusterVarianceQualityMeasure; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.NumberVector; -import de.lmu.ifi.dbs.elki.data.model.MeanModel; -import de.lmu.ifi.dbs.elki.data.type.TypeUtil; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.database.relation.Relation; -import de.lmu.ifi.dbs.elki.distance.distancefunction.PrimitiveDoubleDistanceFunction; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Test cluster quality measure computations. - * - * @author Stephan Baier - */ -public class TestKMeansQualityMeasure extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Test cluster variance. - */ - @Test - public void testVariance() { - Database db = makeSimpleDatabase(UNITTEST + "quality-measure-test.csv", 7); - Relation<DoubleVector> rel = db.getRelation(TypeUtil.DOUBLE_VECTOR_FIELD); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params = new ListParameterization(); - params.addParameter(KMeans.K_ID, 2); - params.addParameter(KMeans.INIT_ID, FirstKInitialMeans.class); - AbstractKMeans<DoubleVector, DoubleDistance, ?> kmeans = ClassGenericsUtil.parameterizeOrAbort(KMeansLloyd.class, params); - testParameterizationOk(params); - - // run KMeans on database - @SuppressWarnings("unchecked") - Clustering<MeanModel<DoubleVector>> result2 = (Clustering<MeanModel<DoubleVector>>) kmeans.run(db); - - // Test Cluster Variance - KMeansQualityMeasure<? super DoubleVector, ? super DoubleDistance> variance = new WithinClusterVarianceQualityMeasure(); - @SuppressWarnings("unchecked") - final PrimitiveDoubleDistanceFunction<NumberVector<?>> dist = (PrimitiveDoubleDistanceFunction<NumberVector<?>>) kmeans.getDistanceFunction(); - - final double quality = variance.calculateCost(result2, dist, rel); - assertEquals("Within cluster variance incorrect", 3.16666666666, quality, 1e-10); - } - - /** - * Test cluster average overall distance. - */ - @Test - public void testOverallDistance() { - - Database db = makeSimpleDatabase(UNITTEST + "quality-measure-test.csv", 7); - Relation<DoubleVector> rel = db.getRelation(TypeUtil.DOUBLE_VECTOR_FIELD); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params = new ListParameterization(); - params.addParameter(KMeans.K_ID, 2); - params.addParameter(KMeans.INIT_ID, FirstKInitialMeans.class); - AbstractKMeans<DoubleVector, DoubleDistance, ?> kmeans = ClassGenericsUtil.parameterizeOrAbort(KMeansLloyd.class, params); - testParameterizationOk(params); - - // run KMeans on database - @SuppressWarnings("unchecked") - Clustering<MeanModel<DoubleVector>> result = (Clustering<MeanModel<DoubleVector>>) kmeans.run(db); - @SuppressWarnings("unchecked") - final PrimitiveDoubleDistanceFunction<NumberVector<?>> dist = (PrimitiveDoubleDistanceFunction<NumberVector<?>>) kmeans.getDistanceFunction(); - - // Test Cluster Average Overall Distance - KMeansQualityMeasure<? super DoubleVector, ? super DoubleDistance> overall = new WithinClusterMeanDistanceQualityMeasure(); - final double quality = overall.calculateCost(result, dist, rel); - - assertEquals("Avarage overall distance not as expected.", 0.8888888888888888, quality, 1e-10); - } -} diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansResults.java deleted file mode 100644 index 3601b977..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansResults.java +++ /dev/null @@ -1,163 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.kmeans; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.clustering.kmeans.KMeansLloyd; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.MeanModel; -import de.lmu.ifi.dbs.elki.data.model.MedoidModel; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Performs a full KMeans run, and compares the result with a clustering derived - * from the data set labels. This test ensures that KMeans's performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Katharina Rausch - * @author Erich Schubert - */ -public class TestKMeansResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run KMeans with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testKMeansLloyd() { - Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d-no-noise.ascii", 1000); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(KMeans.K_ID, 5); - params.addParameter(KMeans.SEED_ID, 2); - AbstractKMeans<DoubleVector, DoubleDistance, ?> kmeans = ClassGenericsUtil.parameterizeOrAbort(KMeansLloyd.class, params); - testParameterizationOk(params); - - // run KMeans on database - Clustering<? extends MeanModel<DoubleVector>> result = kmeans.run(db); - testFMeasure(db, result, 0.998005); - testClusterSizes(result, new int[] { 199, 200, 200, 200, 201 }); - } - - /** - * Run KMeans with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testKMeansMacQueen() { - Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d-no-noise.ascii", 1000); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(KMeans.K_ID, 5); - params.addParameter(KMeans.SEED_ID, 2); - AbstractKMeans<DoubleVector, DoubleDistance, ?> kmeans = ClassGenericsUtil.parameterizeOrAbort(KMeansMacQueen.class, params); - testParameterizationOk(params); - - // run KMeans on database - Clustering<? extends MeanModel<DoubleVector>> result = kmeans.run(db); - testFMeasure(db, result, 0.998005); - testClusterSizes(result, new int[] { 199, 200, 200, 200, 201 }); - } - - /** - * Run KMedians with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testKMediansLloyd() { - Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d-no-noise.ascii", 1000); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(KMeans.K_ID, 5); - params.addParameter(KMeans.SEED_ID, 2); - AbstractKMeans<DoubleVector, DoubleDistance, ?> kmedians = ClassGenericsUtil.parameterizeOrAbort(KMediansLloyd.class, params); - testParameterizationOk(params); - - // run KMedians on database - Clustering<? extends MeanModel<DoubleVector>> result = kmedians.run(db); - testFMeasure(db, result, 0.998005); - testClusterSizes(result, new int[] { 199, 200, 200, 200, 201 }); - } - - /** - * Run KMedians PAM with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testKMedoidsPAM() { - Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d-no-noise.ascii", 1000); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(KMeans.K_ID, 5); - KMedoidsPAM<DoubleVector, DoubleDistance> kmedians = ClassGenericsUtil.parameterizeOrAbort(KMedoidsPAM.class, params); - testParameterizationOk(params); - - // run KMedians on database - Clustering<MedoidModel> result = kmedians.run(db); - testFMeasure(db, result, 0.998005); - testClusterSizes(result, new int[] { 199, 200, 200, 200, 201 }); - } - - /** - * Run KMedoidsEM with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testKMedoidsEM() { - Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d-no-noise.ascii", 1000); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(KMeans.K_ID, 5); - KMedoidsEM<DoubleVector, DoubleDistance> kmedians = ClassGenericsUtil.parameterizeOrAbort(KMedoidsEM.class, params); - testParameterizationOk(params); - - // run KMedians on database - Clustering<MedoidModel> result = kmedians.run(db); - testFMeasure(db, result, 0.998005); - testClusterSizes(result, new int[] { 199, 200, 200, 200, 201 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestCLIQUEResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestCLIQUEResults.java deleted file mode 100644 index 726efd76..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestCLIQUEResults.java +++ /dev/null @@ -1,98 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.subspace; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.SubspaceModel; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Performs a full CLIQUE run, and compares the result with a clustering derived - * from the data set labels. This test ensures that CLIQUE performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Elke Achtert - * @author Katharina Rausch - * @author Erich Schubert - */ -public class TestCLIQUEResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run CLIQUE with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testCLIQUEResults() { - Database db = makeSimpleDatabase(UNITTEST + "subspace-simple.csv", 600); - - ListParameterization params = new ListParameterization(); - params.addParameter(CLIQUE.TAU_ID, "0.1"); - params.addParameter(CLIQUE.XSI_ID, 20); - - // setup algorithm - CLIQUE<DoubleVector> clique = ClassGenericsUtil.parameterizeOrAbort(CLIQUE.class, params); - testParameterizationOk(params); - - // run CLIQUE on database - Clustering<SubspaceModel<DoubleVector>> result = clique.run(db); - - // PairCounting is not appropriate here: overlapping clusterings! - // testFMeasure(db, result, 0.9882); - testClusterSizes(result, new int[] { 200, 200, 216, 400 }); - } - - /** - * Run CLIQUE with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testCLIQUESubspaceOverlapping() { - Database db = makeSimpleDatabase(UNITTEST + "subspace-overlapping-3-4d.ascii", 850); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(CLIQUE.TAU_ID, 0.2); - params.addParameter(CLIQUE.XSI_ID, 6); - CLIQUE<DoubleVector> clique = ClassGenericsUtil.parameterizeOrAbort(CLIQUE.class, params); - testParameterizationOk(params); - - // run CLIQUE on database - Clustering<SubspaceModel<DoubleVector>> result = clique.run(db); - // PairCounting is not appropriate here: overlapping clusterings! - // testFMeasure(db, result, 0.433661); - testClusterSizes(result, new int[] { 255, 409, 458, 458, 480 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestDiSHResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestDiSHResults.java deleted file mode 100644 index c7be9747..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestDiSHResults.java +++ /dev/null @@ -1,94 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.subspace; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.SubspaceModel; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Performs a full DiSH run, and compares the result with a clustering derived - * from the data set labels. This test ensures that DiSH performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Elke Achtert - * @author Katharina Rausch - * @author Erich Schubert - */ -public class TestDiSHResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run DiSH with fixed parameters and compare the result to a golden standard. - * - * @throws ParameterException - */ - @Test - public void testDiSHResults() { - Database db = makeSimpleDatabase(UNITTEST + "subspace-hierarchy.csv", 450); - - ListParameterization params = new ListParameterization(); - params.addParameter(DiSH.EPSILON_ID, 0.005); - params.addParameter(DiSH.MU_ID, 50); - - // setup algorithm - DiSH<DoubleVector> dish = ClassGenericsUtil.parameterizeOrAbort(DiSH.class, params); - testParameterizationOk(params); - - // run DiSH on database - Clustering<SubspaceModel<DoubleVector>> result = dish.run(db); - - testFMeasure(db, result, 0.996976); // Hierarchical pairs scored: 0.9991258 - testClusterSizes(result, new int[] { 51, 199, 200 }); - } - - /** - * Run DiSH with fixed parameters and compare the result to a golden standard. - * - * @throws ParameterException - */ - @Test - public void testDiSHSubspaceOverlapping() { - Database db = makeSimpleDatabase(UNITTEST + "subspace-overlapping-4-5d.ascii", 1100); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(DiSH.EPSILON_ID, 0.1); - params.addParameter(DiSH.MU_ID, 30); - DiSH<DoubleVector> dish = ClassGenericsUtil.parameterizeOrAbort(DiSH.class, params); - testParameterizationOk(params); - - // run DiSH on database - Clustering<SubspaceModel<DoubleVector>> result = dish.run(db); - testFMeasure(db, result, 0.6376870); - testClusterSizes(result, new int[] { 33, 52, 72, 109, 172, 314, 348 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestP3C.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestP3C.java deleted file mode 100644 index 4d02351f..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestP3C.java +++ /dev/null @@ -1,84 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.subspace; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.SubspaceModel; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Test P3C on a simple test data set. - * - * Note: both data sets are really beneficial for P3C, and with reasonably - * chosen parameters, it works perfectly. - * - * @author Erich Schubert - */ -public class TestP3C extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run P3C with fixed parameters and compare the result to a golden standard. - */ - @Test - public void testP3CSimple() { - Database db = makeSimpleDatabase(UNITTEST + "subspace-simple.csv", 600); - - ListParameterization params = new ListParameterization(); - - // setup algorithm - P3C<DoubleVector> p3c = ClassGenericsUtil.parameterizeOrAbort(P3C.class, params); - testParameterizationOk(params); - - // run P3C on database - Clustering<SubspaceModel<DoubleVector>> result = p3c.run(db); - - testFMeasure(db, result, 1.0); - testClusterSizes(result, new int[] { 200, 400 }); - } - - /** - * Run P3C with fixed parameters and compare the result to a golden standard. - */ - @Test - public void testP3COverlapping() { - Database db = makeSimpleDatabase(UNITTEST + "subspace-overlapping-3-4d.ascii", 850); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(P3C.Parameterizer.ALPHA_THRESHOLD_ID, 0.01); - P3C<DoubleVector> p3c = ClassGenericsUtil.parameterizeOrAbort(P3C.class, params); - testParameterizationOk(params); - - // run P3C on database - Clustering<SubspaceModel<DoubleVector>> result = p3c.run(db); - testFMeasure(db, result, 1.0); - testClusterSizes(result, new int[] { 150, 300, 400 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestPROCLUSResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestPROCLUSResults.java deleted file mode 100644 index bfb94ee3..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestPROCLUSResults.java +++ /dev/null @@ -1,99 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.subspace; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Performs a full PROCLUS run, and compares the result with a clustering - * derived from the data set labels. This test ensures that PROCLUS performance - * doesn't unexpectedly drop on this data set (and also ensures that the - * algorithms work, as a side effect). - * - * @author Elke Achtert - * @author Katharina Rausch - * @author Erich Schubert - */ -public class TestPROCLUSResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run PROCLUS with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testPROCLUSResults() { - Database db = makeSimpleDatabase(UNITTEST + "subspace-simple.csv", 600); - - ListParameterization params = new ListParameterization(); - params.addParameter(PROCLUS.Parameterizer.L_ID, 1); - params.addParameter(PROCLUS.Parameterizer.K_ID, 4); - // NOTE: PROCLUS quality heavily depends on random... - params.addParameter(PROCLUS.Parameterizer.SEED_ID, 0); - - // setup algorithm - PROCLUS<DoubleVector> proclus = ClassGenericsUtil.parameterizeOrAbort(PROCLUS.class, params); - testParameterizationOk(params); - - // run PROCLUS on database - Clustering<?> result = proclus.run(db); - - testFMeasure(db, result, 0.6946958); - testClusterSizes(result, new int[] { 45, 151, 200, 204 }); - } - - /** - * Run PROCLUS with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testPROCLUSSubspaceOverlapping() { - Database db = makeSimpleDatabase(UNITTEST + "subspace-overlapping-3-4d.ascii", 850); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(PROCLUS.Parameterizer.L_ID, 2); - params.addParameter(PROCLUS.Parameterizer.K_ID, 3); - // NOTE: PROCLUS quality heavily depends on random... - params.addParameter(PROCLUS.Parameterizer.SEED_ID, 1); - PROCLUS<DoubleVector> proclus = ClassGenericsUtil.parameterizeOrAbort(PROCLUS.class, params); - testParameterizationOk(params); - - // run PROCLUS on database - Clustering<?> result = proclus.run(db); - testFMeasure(db, result, 0.7812455); - testClusterSizes(result, new int[] { 111, 269, 470 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestPreDeConResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestPreDeConResults.java deleted file mode 100644 index d00a703f..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestPreDeConResults.java +++ /dev/null @@ -1,109 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.subspace; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractProjectedDBSCAN; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.Model; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.datasource.filter.ClassLabelFilter; -import de.lmu.ifi.dbs.elki.index.preprocessed.subspaceproj.PreDeConSubspaceIndex.Factory; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Perform a full PreDeCon run, and compare the result with a clustering derived - * from the data set labels. This test ensures that PreDeCon performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Erich Schubert - * @author Katharina Rausch - */ -public class TestPreDeConResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run PreDeCon with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testPreDeConResults() { - // Additional input parameters - ListParameterization inp = new ListParameterization(); - inp.addParameter(ClassLabelFilter.Parameterizer.CLASS_LABEL_INDEX_ID, 1); - Class<?>[] filters = new Class<?>[] { ClassLabelFilter.class }; - Database db = makeSimpleDatabase(UNITTEST + "axis-parallel-subspace-clusters-6d.csv.gz", 2500, inp, filters); - - ListParameterization params = new ListParameterization(); - // PreDeCon - // FIXME: These parameters do NOT work... - params.addParameter(AbstractProjectedDBSCAN.EPSILON_ID, 50); - params.addParameter(AbstractProjectedDBSCAN.MINPTS_ID, 50); - params.addParameter(AbstractProjectedDBSCAN.LAMBDA_ID, 2); - - // setup algorithm - PreDeCon<DoubleVector> predecon = ClassGenericsUtil.parameterizeOrAbort(PreDeCon.class, params); - testParameterizationOk(params); - - // run PredeCon on database - Clustering<Model> result = predecon.run(db); - - // FIXME: find working parameters... - testFMeasure(db, result, 0.40153); - testClusterSizes(result, new int[] { 2500 }); - } - - /** - * Run PreDeCon with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testPreDeConSubspaceOverlapping() { - Database db = makeSimpleDatabase(UNITTEST + "subspace-overlapping-3-4d.ascii", 850); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - // PreDeCon - params.addParameter(AbstractProjectedDBSCAN.EPSILON_ID, 2.0); - params.addParameter(AbstractProjectedDBSCAN.MINPTS_ID, 7); - params.addParameter(AbstractProjectedDBSCAN.LAMBDA_ID, 4); - params.addParameter(Factory.DELTA_ID, 0.04); - PreDeCon<DoubleVector> predecon = ClassGenericsUtil.parameterizeOrAbort(PreDeCon.class, params); - testParameterizationOk(params); - - // run PredeCon on database - Clustering<Model> result = predecon.run(db); - testFMeasure(db, result, 0.6470817); - testClusterSizes(result, new int[] { 7, 10, 10, 13, 15, 16, 16, 18, 28, 131, 586 }); - } -} diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestSUBCLUResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestSUBCLUResults.java deleted file mode 100644 index 817687c5..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestSUBCLUResults.java +++ /dev/null @@ -1,98 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.clustering.subspace; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.Clustering; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.model.SubspaceModel; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Performs a full SUBCLU run, and compares the result with a clustering derived - * from the data set labels. This test ensures that SUBCLU performance doesn't - * unexpectedly drop on this data set (and also ensures that the algorithms - * work, as a side effect). - * - * @author Elke Achtert - * @author Katharina Rausch - * @author Erich Schubert - */ -public class TestSUBCLUResults extends AbstractSimpleAlgorithmTest implements JUnit4Test { - /** - * Run SUBCLU with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testSUBCLUResults() { - Database db = makeSimpleDatabase(UNITTEST + "subspace-simple.csv", 600); - - ListParameterization params = new ListParameterization(); - params.addParameter(SUBCLU.EPSILON_ID, 0.001); - params.addParameter(SUBCLU.MINPTS_ID, 100); - - // setup algorithm - SUBCLU<DoubleVector> subclu = ClassGenericsUtil.parameterizeOrAbort(SUBCLU.class, params); - testParameterizationOk(params); - - // run SUBCLU on database - Clustering<SubspaceModel<DoubleVector>> result = subclu.run(db); - - // PairCounting is not appropriate here: overlapping clusterings! - // testFMeasure(db, result, 0.9090); - testClusterSizes(result, new int[] { 191, 194, 395 }); - } - - /** - * Run SUBCLU with fixed parameters and compare the result to a golden - * standard. - * - * @throws ParameterException - */ - @Test - public void testSUBCLUSubspaceOverlapping() { - Database db = makeSimpleDatabase(UNITTEST + "subspace-overlapping-3-4d.ascii", 850); - - // Setup algorithm - ListParameterization params = new ListParameterization(); - params.addParameter(SUBCLU.EPSILON_ID, 0.04); - params.addParameter(SUBCLU.MINPTS_ID, 70); - SUBCLU<DoubleVector> subclu = ClassGenericsUtil.parameterizeOrAbort(SUBCLU.class, params); - testParameterizationOk(params); - - // run SUBCLU on database - Clustering<SubspaceModel<DoubleVector>> result = subclu.run(db); - // PairCounting is not appropriate here: overlapping clusterings! - // testFMeasure(db, result, 0.49279033); - testClusterSizes(result, new int[] { 99, 247, 303, 323, 437, 459 }); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestABOD.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestABOD.java deleted file mode 100644 index e213b54e..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestABOD.java +++ /dev/null @@ -1,60 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the ABOD algorithm. - * - * Note: we don't implement JUnit4Test, as this test is slow. - * - * @author Lucia Cichella - */ -public class TestABOD extends AbstractSimpleAlgorithmTest { - @Test - public void testABOD() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960); - - // Parameterization - ListParameterization params = new ListParameterization(); - - // setup Algorithm - ABOD<DoubleVector> abod = ClassGenericsUtil.parameterizeOrAbort(ABOD.class, params); - testParameterizationOk(params); - - // run ABOD on database - OutlierResult result = abod.run(db); - - testAUC(db, "Noise", result, 0.94887037037037); - testSingleScore(result, 945, 1.88108120738508E-4); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestAggarwalYuEvolutionary.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestAggarwalYuEvolutionary.java deleted file mode 100644 index cabd315a..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestAggarwalYuEvolutionary.java +++ /dev/null @@ -1,63 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the AggarwalYuEvolutionary algorithm. - * - * @author Lucia Cichella - */ -public class TestAggarwalYuEvolutionary extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testAggarwalYuEvolutionary() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(AggarwalYuEvolutionary.Parameterizer.K_ID, 2); - params.addParameter(AggarwalYuEvolutionary.Parameterizer.PHI_ID, 8); - params.addParameter(AggarwalYuEvolutionary.Parameterizer.M_ID, 5); - params.addParameter(AggarwalYuEvolutionary.Parameterizer.SEED_ID, 0); - - // setup Algorithm - AggarwalYuEvolutionary<DoubleVector> aggarwalYuEvolutionary = ClassGenericsUtil.parameterizeOrAbort(AggarwalYuEvolutionary.class, params); - testParameterizationOk(params); - - // run AggarwalYuEvolutionary on database - OutlierResult result = aggarwalYuEvolutionary.run(db); - - testSingleScore(result, 945, 16.6553612449883); - testAUC(db, "Noise", result, 0.5799537037037); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestAggarwalYuNaive.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestAggarwalYuNaive.java deleted file mode 100644 index 016fe5e5..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestAggarwalYuNaive.java +++ /dev/null @@ -1,61 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the AggarwalYuNaive algorithm. - * - * @author Lucia Cichella - */ -public class TestAggarwalYuNaive extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testAggarwalYuNaive() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(AggarwalYuNaive.Parameterizer.K_ID, 2); - params.addParameter(AggarwalYuNaive.Parameterizer.PHI_ID, 8); - - // setup Algorithm - AggarwalYuNaive<DoubleVector> aggarwalYuNaive = ClassGenericsUtil.parameterizeOrAbort(AggarwalYuNaive.class, params); - testParameterizationOk(params); - - // run AggarwalYuNaive on database - OutlierResult result = aggarwalYuNaive.run(db); - - testSingleScore(result, 945, -2.3421601750764798); - testAUC(db, "Noise", result, 0.8652037037037); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestDBOutlierDetection.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestDBOutlierDetection.java deleted file mode 100644 index 0d6fc7f6..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestDBOutlierDetection.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the DBOutlierDetection algorithm. - * - * @author Lucia Cichella - */ -public class TestDBOutlierDetection extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testDBOutlierDetection() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-fire.ascii", 1025); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(DBOutlierDetection.D_ID, 0.175); - params.addParameter(DBOutlierDetection.P_ID, 0.98); - - // setup Algorithm - DBOutlierDetection<DoubleVector, DoubleDistance> dbOutlierDetection = ClassGenericsUtil.parameterizeOrAbort(DBOutlierDetection.class, params); - testParameterizationOk(params); - - // run DBOutlierDetection on database - OutlierResult result = dbOutlierDetection.run(db); - - testSingleScore(result, 1025, 0.0); - testAUC(db, "Noise", result, 0.97487179); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestDBOutlierScore.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestDBOutlierScore.java deleted file mode 100644 index b34c071e..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestDBOutlierScore.java +++ /dev/null @@ -1,61 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the DBOutlierScore algorithm. - * - * @author Lucia Cichella - */ -public class TestDBOutlierScore extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testDBOutlierScore() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-fire.ascii", 1025); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(DBOutlierScore.D_ID, 0.175); - - // setup Algorithm - DBOutlierScore<DoubleVector, DoubleDistance> dbOutlierScore = ClassGenericsUtil.parameterizeOrAbort(DBOutlierScore.class, params); - testParameterizationOk(params); - - // run DBOutlierScore on database - OutlierResult result = dbOutlierScore.run(db); - - testSingleScore(result, 1025, 0.688780487804878); - testAUC(db, "Noise", result, 0.992565641); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestFastABOD.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestFastABOD.java deleted file mode 100644 index 11977af6..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestFastABOD.java +++ /dev/null @@ -1,60 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the ABOD algorithm. - * - * @author Lucia Cichella - */ -public class TestFastABOD extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testFastABOD() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(FastABOD.Parameterizer.K_ID, 5); - - // setup Algorithm - FastABOD<DoubleVector> abod = ClassGenericsUtil.parameterizeOrAbort(FastABOD.class, params); - testParameterizationOk(params); - - // run ABOD on database - OutlierResult result = abod.run(db); - - testAUC(db, "Noise", result, 0.963259259259); - testSingleScore(result, 945, 0.68723169783); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestGaussianModel.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestGaussianModel.java deleted file mode 100644 index e18c2f46..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestGaussianModel.java +++ /dev/null @@ -1,59 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the GaussianModel algorithm. - * - * @author Lucia Cichella - */ -public class TestGaussianModel extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testGaussianModel() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-fire.ascii", 1025); - - // Parameterization - ListParameterization params = new ListParameterization(); - - // setup Algorithm - GaussianModel<DoubleVector> gaussianModel = ClassGenericsUtil.parameterizeOrAbort(GaussianModel.class, params); - testParameterizationOk(params); - - // run GaussianModel on database - OutlierResult result = gaussianModel.run(db); - - testSingleScore(result, 1025, 2.8312466458765426); - testAUC(db, "Noise", result, 0.9937641025641025); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestGaussianUniformMixture.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestGaussianUniformMixture.java deleted file mode 100644 index c02da8a5..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestGaussianUniformMixture.java +++ /dev/null @@ -1,59 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the GaussianUniformMixture algorithm. - * - * @author Lucia Cichella - */ -public class TestGaussianUniformMixture extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testGaussianUniformMixture() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-fire.ascii", 1025); - - // Parameterization - ListParameterization params = new ListParameterization(); - - // setup Algorithm - GaussianUniformMixture<DoubleVector> gaussianUniformMixture = ClassGenericsUtil.parameterizeOrAbort(GaussianUniformMixture.class, params); - testParameterizationOk(params); - - // run GaussianUniformMixture on database - OutlierResult result = gaussianUniformMixture.run(db); - - testSingleScore(result, 1025, -20.2862041); - testAUC(db, "Noise", result, 0.94404102); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestKNNOutlier.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestKNNOutlier.java deleted file mode 100644 index 7d0457df..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestKNNOutlier.java +++ /dev/null @@ -1,61 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the KNNOutlier algorithm. - * - * @author Lucia Cichella - */ -public class TestKNNOutlier extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testKNNOutlier() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(KNNOutlier.K_ID, 2); - - // setup Algorithm - KNNOutlier<DoubleVector, DoubleDistance> knnOutlier = ClassGenericsUtil.parameterizeOrAbort(KNNOutlier.class, params); - testParameterizationOk(params); - - // run KNNOutlier on database - OutlierResult result = knnOutlier.run(db); - - testSingleScore(result, 945, 0.4793554700168577); - testAUC(db, "Noise", result, 0.991462962962963); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestKNNWeightOutlier.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestKNNWeightOutlier.java deleted file mode 100644 index bbb1bdfb..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestKNNWeightOutlier.java +++ /dev/null @@ -1,61 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the KNNWeightOutlier algorithm. - * - * @author Lucia Cichella - */ -public class TestKNNWeightOutlier extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testKNNWeightOutlier() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(KNNWeightOutlier.K_ID, 5); - - // setup Algorithm - KNNWeightOutlier<DoubleVector, DoubleDistance> knnWeightOutlier = ClassGenericsUtil.parameterizeOrAbort(KNNWeightOutlier.class, params); - testParameterizationOk(params); - - // run KNNWeightOutlier on database - OutlierResult result = knnWeightOutlier.run(db); - - testSingleScore(result, 945, 2.384117261027324); - testAUC(db, "Noise", result, 0.9912777777777778); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestLBABOD.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestLBABOD.java deleted file mode 100644 index 5a1f56f2..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestLBABOD.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the LB-ABOD algorithm. - * - * Note: we don't implement JUnit4Test, as this test is slow. - * - * @author Lucia Cichella - */ -public class TestLBABOD extends AbstractSimpleAlgorithmTest { - @Test - public void testLBABOD() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(FastABOD.Parameterizer.K_ID, 150); - params.addParameter(LBABOD.Parameterizer.L_ID, 10); - - // setup Algorithm - LBABOD<DoubleVector> abod = ClassGenericsUtil.parameterizeOrAbort(LBABOD.class, params); - testParameterizationOk(params); - - // run ABOD on database - OutlierResult result = abod.run(db); - - testAUC(db, "Noise", result, 0.928999999999); - testSingleScore(result, 945, 1.88108120738508E-4); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestOPTICSOF.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestOPTICSOF.java deleted file mode 100644 index ed9e1533..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestOPTICSOF.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.clustering.OPTICS; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the OPTICS-OF algorithm. - * - * @author Lucia Cichella - */ -public class TestOPTICSOF extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testOPTICSOF() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-parabolic.ascii", 530); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(OPTICS.MINPTS_ID, 22); - - // setup Algorithm - OPTICSOF<DoubleVector, DoubleDistance> opticsof = ClassGenericsUtil.parameterizeOrAbort(OPTICSOF.class, params); - testParameterizationOk(params); - - // run OPTICSOF on database - OutlierResult result = opticsof.run(db); - - testSingleScore(result, 416, 1.6108343626651815); - testAUC(db, "Noise", result, 0.9058); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestReferenceBasedOutlierDetection.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestReferenceBasedOutlierDetection.java deleted file mode 100644 index 5b6d3bde..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestReferenceBasedOutlierDetection.java +++ /dev/null @@ -1,63 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; -import de.lmu.ifi.dbs.elki.utilities.referencepoints.GridBasedReferencePoints; - -/** - * Tests the ReferenceBasedOutlierDetection algorithm. - * - * @author Lucia Cichella - */ -public class TestReferenceBasedOutlierDetection extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testReferenceBasedOutlierDetection() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(ReferenceBasedOutlierDetection.K_ID, 11); - params.addParameter(GridBasedReferencePoints.GRID_ID, 11); - - // setup Algorithm - ReferenceBasedOutlierDetection<DoubleVector, DoubleDistance> referenceBasedOutlierDetection = ClassGenericsUtil.parameterizeOrAbort(ReferenceBasedOutlierDetection.class, params); - testParameterizationOk(params); - - // run ReferenceBasedOutlierDetection on database - OutlierResult result = referenceBasedOutlierDetection.run(db); - - testSingleScore(result, 945, 0.9260829537195538); - testAUC(db, "Noise", result, 0.9892407407407409); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestINFLO.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestINFLO.java deleted file mode 100644 index 99b97d92..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestINFLO.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier.lof; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.outlier.lof.INFLO; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the INFLO algorithm. - * - * @author Lucia Cichella - */ -public class TestINFLO extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testINFLO() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(INFLO.K_ID, 29); - - // setup Algorithm - INFLO<DoubleVector, DoubleDistance> inflo = ClassGenericsUtil.parameterizeOrAbort(INFLO.class, params); - testParameterizationOk(params); - - // run INFLO on database - OutlierResult result = inflo.run(db); - - testSingleScore(result, 945, 1.215459716); - testAUC(db, "Noise", result, 0.9389259259259); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLDOF.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLDOF.java deleted file mode 100644 index 370054ea..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLDOF.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier.lof; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.outlier.lof.LDOF; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the LDOF algorithm. - * - * @author Lucia Cichella - */ -public class TestLDOF extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testLDOF() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-fire.ascii", 1025); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(LDOF.K_ID, 25); - - // setup Algorithm - LDOF<DoubleVector, DoubleDistance> ldof = ClassGenericsUtil.parameterizeOrAbort(LDOF.class, params); - testParameterizationOk(params); - - // run LDOF on database - OutlierResult result = ldof.run(db); - - testAUC(db, "Noise", result, 0.9637948717948718); - testSingleScore(result, 1025, 0.8976268846182947); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLOCI.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLOCI.java deleted file mode 100644 index 05206f55..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLOCI.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier.lof; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.outlier.lof.LOCI; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the LOCI algorithm. - * - * @author Lucia Cichella - */ -public class TestLOCI extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testLOCI() { - Database db = makeSimpleDatabase(UNITTEST + "3clusters-and-noise-2d.csv", 330); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(LOCI.RMAX_ID, 0.5); - - // setup Algorithm - LOCI<DoubleVector, DoubleDistance> loci = ClassGenericsUtil.parameterizeOrAbort(LOCI.class, params); - testParameterizationOk(params); - - // run LOCI on database - OutlierResult result = loci.run(db); - - testAUC(db, "Noise", result, 0.96222222); - testSingleScore(result, 146, 3.8054382); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLOF.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLOF.java deleted file mode 100644 index 2c7bbd1d..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLOF.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier.lof; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.outlier.lof.LOF; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the LOF algorithm. - * - * @author Lucia Cichella - */ -public class TestLOF extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testLOF() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-axis-subspaces-6d.ascii", 1345); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(LOF.Parameterizer.K_ID, 10); - - // setup Algorithm - LOF<DoubleVector, DoubleDistance> lof = ClassGenericsUtil.parameterizeOrAbort(LOF.class, params); - testParameterizationOk(params); - - // run LOF on database - OutlierResult result = lof.run(db); - - testSingleScore(result, 1293, 1.1945314199156365); - testAUC(db, "Noise", result, 0.8921680672268908); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLoOP.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLoOP.java deleted file mode 100644 index e6670eb7..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestLoOP.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier.lof; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.outlier.lof.LoOP; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the LoOP algorithm. - * - * @author Lucia Cichella - */ -public class TestLoOP extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testLoOP() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(LoOP.KCOMP_ID, 15); - - // setup Algorithm - LoOP<DoubleVector, DoubleDistance> loop = ClassGenericsUtil.parameterizeOrAbort(LoOP.class, params); - testParameterizationOk(params); - - // run LoOP on database - OutlierResult result = loop.run(db); - - testAUC(db, "Noise", result, 0.9443796296296296); - testSingleScore(result, 945, 0.39805457858293325); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestOnlineLOF.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestOnlineLOF.java deleted file mode 100644 index 889cddce..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestOnlineLOF.java +++ /dev/null @@ -1,168 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier.lof; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.Random; - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.outlier.lof.FlexibleLOF; -import de.lmu.ifi.dbs.elki.algorithm.outlier.lof.LOF; -import de.lmu.ifi.dbs.elki.algorithm.outlier.lof.OnlineLOF; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.data.NumberVector; -import de.lmu.ifi.dbs.elki.data.VectorUtil; -import de.lmu.ifi.dbs.elki.data.type.TypeUtil; -import de.lmu.ifi.dbs.elki.database.HashmapDatabase; -import de.lmu.ifi.dbs.elki.database.UpdatableDatabase; -import de.lmu.ifi.dbs.elki.database.ids.DBIDIter; -import de.lmu.ifi.dbs.elki.database.ids.DBIDUtil; -import de.lmu.ifi.dbs.elki.database.ids.DBIDs; -import de.lmu.ifi.dbs.elki.database.relation.Relation; -import de.lmu.ifi.dbs.elki.database.relation.RelationUtil; -import de.lmu.ifi.dbs.elki.datasource.FileBasedDatabaseConnection; -import de.lmu.ifi.dbs.elki.datasource.bundle.MultipleObjectsBundle; -import de.lmu.ifi.dbs.elki.distance.distancefunction.CosineDistanceFunction; -import de.lmu.ifi.dbs.elki.distance.distancefunction.DistanceFunction; -import de.lmu.ifi.dbs.elki.distance.distancefunction.minkowski.EuclideanDistanceFunction; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.exceptions.UnableToComplyException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the OnlineLOF algorithm. Compares the result of the static LOF - * algorithm to the result of the OnlineLOF algorithm, where some insertions and - * deletions (of the previously inserted objects) have been applied to the - * database. - * - * @author Elke Achtert - * - */ -public class TestOnlineLOF implements JUnit4Test { - // the following values depend on the data set used! - static String dataset = "data/testdata/unittests/3clusters-and-noise-2d.csv"; - - // parameter k for LOF and OnlineLOF - static int k = 5; - - // neighborhood distance function for LOF and OnlineLOF - @SuppressWarnings("rawtypes") - static DistanceFunction neighborhoodDistanceFunction = EuclideanDistanceFunction.STATIC; - - // reachability distance function for LOF and OnlineLOF - @SuppressWarnings("rawtypes") - static DistanceFunction reachabilityDistanceFunction = CosineDistanceFunction.STATIC; - - // seed for the generator - static int seed = 5; - - // size of the data set - static int size = 50; - - /** - * First, run the {@link LOF} algorithm on the database. Second, run the - * {@link OnlineLOF} algorithm on the database, insert new objects and - * afterwards delete them. Then, compare the two results for equality. - * - * @throws UnableToComplyException - */ - @SuppressWarnings("unchecked") - @Test - public void testOnlineLOF() throws UnableToComplyException { - UpdatableDatabase db = getDatabase(); - - // 1. Run LOF - FlexibleLOF<DoubleVector, DoubleDistance> lof = new FlexibleLOF<>(k, k, neighborhoodDistanceFunction, reachabilityDistanceFunction); - OutlierResult result1 = lof.run(db); - - // 2. Run OnlineLOF (with insertions and removals) on database - OutlierResult result2 = runOnlineLOF(db); - - // 3. Compare results - Relation<Double> scores1 = result1.getScores(); - Relation<Double> scores2 = result2.getScores(); - - for(DBIDIter id = scores1.getDBIDs().iter(); id.valid(); id.advance()) { - Double lof1 = scores1.get(id); - Double lof2 = scores2.get(id); - assertTrue("lof(" + DBIDUtil.toString(id) + ") != lof(" + DBIDUtil.toString(id) + "): " + lof1 + " != " + lof2, lof1.equals(lof2)); - } - } - - /** - * Run OnlineLOF (with insertions and removals) on database. - */ - @SuppressWarnings("unchecked") - private static OutlierResult runOnlineLOF(UpdatableDatabase db) throws UnableToComplyException { - Relation<DoubleVector> rep = db.getRelation(TypeUtil.DOUBLE_VECTOR_FIELD); - - // setup algorithm - OnlineLOF<DoubleVector, DoubleDistance> lof = new OnlineLOF<>(k, k, neighborhoodDistanceFunction, reachabilityDistanceFunction); - - // run OnlineLOF on database - OutlierResult result = lof.run(db); - - // insert new objects - ArrayList<DoubleVector> insertions = new ArrayList<>(); - NumberVector.Factory<DoubleVector, ?> o = RelationUtil.getNumberVectorFactory(rep); - int dim = RelationUtil.dimensionality(rep); - Random random = new Random(seed); - for(int i = 0; i < size; i++) { - DoubleVector obj = VectorUtil.randomVector(o, dim, random); - insertions.add(obj); - } - DBIDs deletions = db.insert(MultipleObjectsBundle.makeSimple(rep.getDataTypeInformation(), insertions)); - - // delete objects - db.delete(deletions); - - return result; - } - - /** - * Returns the database. - */ - private static UpdatableDatabase getDatabase() { - ListParameterization params = new ListParameterization(); - params.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, dataset); - - UpdatableDatabase db = ClassGenericsUtil.parameterizeOrAbort(HashmapDatabase.class, params); - params.failOnErrors(); - if(params.hasUnusedParameters()) { - fail("Unused parameters: " + params.getRemainingParameters()); - } - - // get database - db.initialize(); - return db; - } - -} diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/meta/TestFeatureBagging.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/meta/TestFeatureBagging.java deleted file mode 100644 index c3d9f7a0..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/meta/TestFeatureBagging.java +++ /dev/null @@ -1,84 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier.meta; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.outlier.lof.LOF; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the Feature Bagging algorithm. - * - * @author Erich Schubert - */ -public class TestFeatureBagging extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testFeatureBaggingSum() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-axis-subspaces-6d.ascii", 1345); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(LOF.Parameterizer.K_ID, 10); - params.addParameter(FeatureBagging.Parameterizer.NUM_ID, 10); - params.addParameter(FeatureBagging.Parameterizer.SEED_ID, 1); - - // setup Algorithm - FeatureBagging fb = ClassGenericsUtil.parameterizeOrAbort(FeatureBagging.class, params); - testParameterizationOk(params); - - // run AggarwalYuEvolutionary on database - OutlierResult result = fb.run(db); - - testSingleScore(result, 1293, 11.8295414); - testAUC(db, "Noise", result, 0.9066106); - } - - @Test - public void testFeatureBaggingBreadth() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-axis-subspaces-6d.ascii", 1345); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(LOF.Parameterizer.K_ID, 10); - params.addParameter(FeatureBagging.Parameterizer.NUM_ID, 10); - params.addParameter(FeatureBagging.Parameterizer.SEED_ID, 5); - params.addFlag(FeatureBagging.Parameterizer.BREADTH_ID); - - // setup Algorithm - FeatureBagging fb = ClassGenericsUtil.parameterizeOrAbort(FeatureBagging.class, params); - testParameterizationOk(params); - - // run AggarwalYuEvolutionary on database - OutlierResult result = fb.run(db); - - testSingleScore(result, 1293, 1.321709879); - testAUC(db, "Noise", result, 0.884212); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/meta/TestHiCS.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/meta/TestHiCS.java deleted file mode 100644 index e1ed1f37..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/meta/TestHiCS.java +++ /dev/null @@ -1,88 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier.meta; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.algorithm.outlier.lof.LOF; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.math.statistics.tests.KolmogorovSmirnovTest; -import de.lmu.ifi.dbs.elki.math.statistics.tests.WelchTTest; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the HiCS algorithm. - * - * @author Erich Schubert - */ -public class TestHiCS extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testHiCSKS() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-axis-subspaces-6d.ascii", 1345); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(LOF.Parameterizer.K_ID, 10); - params.addParameter(HiCS.Parameterizer.LIMIT_ID, 10); - params.addParameter(HiCS.Parameterizer.SEED_ID, 0); - params.addParameter(HiCS.Parameterizer.TEST_ID, KolmogorovSmirnovTest.STATIC); - - // setup Algorithm - HiCS<DoubleVector> fb = ClassGenericsUtil.parameterizeOrAbort(HiCS.class, params); - testParameterizationOk(params); - - // run HiCS on database - OutlierResult result = fb.run(db); - - testAUC(db, "Noise", result, 0.85340056); - testSingleScore(result, 1293, 4.935802); - } - - @Test - public void testHiCSWelch() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-axis-subspaces-6d.ascii", 1345); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(LOF.Parameterizer.K_ID, 10); - params.addParameter(HiCS.Parameterizer.LIMIT_ID, 10); - params.addParameter(HiCS.Parameterizer.SEED_ID, 0); - params.addParameter(HiCS.Parameterizer.TEST_ID, WelchTTest.STATIC); - - // setup Algorithm - HiCS<DoubleVector> fb = ClassGenericsUtil.parameterizeOrAbort(HiCS.class, params); - testParameterizationOk(params); - - // run HiCS on database - OutlierResult result = fb.run(db); - - testAUC(db, "Noise", result, 0.6255238); - testSingleScore(result, 1293, 2.542272); - } -}
\ No newline at end of file diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/TestSOD.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/TestSOD.java deleted file mode 100644 index f8f47886..00000000 --- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/TestSOD.java +++ /dev/null @@ -1,63 +0,0 @@ -package de.lmu.ifi.dbs.elki.algorithm.outlier.subspace; - -/* - This file is part of ELKI: - Environment for Developing KDD-Applications Supported by Index-Structures - - Copyright (C) 2012 - Ludwig-Maximilians-Universität München - Lehr- und Forschungseinheit für Datenbanksysteme - ELKI Development Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -import org.junit.Test; - -import de.lmu.ifi.dbs.elki.JUnit4Test; -import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest; -import de.lmu.ifi.dbs.elki.data.DoubleVector; -import de.lmu.ifi.dbs.elki.database.Database; -import de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance; -import de.lmu.ifi.dbs.elki.index.preprocessed.snn.SharedNearestNeighborPreprocessor; -import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; -import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization; - -/** - * Tests the SOD algorithm. - * - * @author Lucia Cichella - */ -public class TestSOD extends AbstractSimpleAlgorithmTest implements JUnit4Test { - @Test - public void testSOD() { - Database db = makeSimpleDatabase(UNITTEST + "outlier-axis-subspaces-6d.ascii", 1345); - - // Parameterization - ListParameterization params = new ListParameterization(); - params.addParameter(SOD.Parameterizer.KNN_ID, 25); - params.addParameter(SharedNearestNeighborPreprocessor.Factory.NUMBER_OF_NEIGHBORS_ID, 19); - - // setup Algorithm - SOD<DoubleVector, DoubleDistance> sod = ClassGenericsUtil.parameterizeOrAbort(SOD.class, params); - testParameterizationOk(params); - - // run SOD on database - OutlierResult result = sod.run(db); - - testSingleScore(result, 1293, 1.5167500); - testAUC(db, "Noise", result, 0.949131652); - } -}
\ No newline at end of file |