Search in sources :

Example 16 with DoubleVector

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

the class CLARANSTest method testCLARANS.

@Test
public void testCLARANS() {
    Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d-no-noise.ascii", 1000);
    Clustering<MedoidModel> result = // 
    new ELKIBuilder<CLARANS<DoubleVector>>(CLARANS.class).with(KMeans.K_ID, // 
    5).with(CLARANS.Parameterizer.RANDOM_ID, // 
    0).with(CLARANS.Parameterizer.NEIGHBORS_ID, // 
    10).with(CLARANS.Parameterizer.RESTARTS_ID, // 
    5).build().run(db);
    testFMeasure(db, result, 0.996);
    testClusterSizes(result, new int[] { 198, 200, 200, 200, 202 });
}
Also used : ELKIBuilder(de.lmu.ifi.dbs.elki.utilities.ELKIBuilder) Database(de.lmu.ifi.dbs.elki.database.Database) DoubleVector(de.lmu.ifi.dbs.elki.data.DoubleVector) MedoidModel(de.lmu.ifi.dbs.elki.data.model.MedoidModel) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest) Test(org.junit.Test)

Example 17 with DoubleVector

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

the class KMeansBatchedLloydTest method testKMeansBatchedLloyd.

/**
 * Run KMeans with fixed parameters and compare the result to a golden
 * standard.
 */
@Test
public void testKMeansBatchedLloyd() {
    Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d-no-noise.ascii", 1000);
    Clustering<?> result = // 
    new ELKIBuilder<KMeansBatchedLloyd<DoubleVector>>(KMeansBatchedLloyd.class).with(KMeans.K_ID, // 
    5).with(KMeans.SEED_ID, // 
    7).with(KMeansBatchedLloyd.Parameterizer.BLOCKS_ID, // 
    10).with(KMeansBatchedLloyd.Parameterizer.RANDOM_ID, // 
    0).build().run(db);
    testFMeasure(db, result, 0.998005);
    testClusterSizes(result, new int[] { 199, 200, 200, 200, 201 });
}
Also used : ELKIBuilder(de.lmu.ifi.dbs.elki.utilities.ELKIBuilder) Database(de.lmu.ifi.dbs.elki.database.Database) DoubleVector(de.lmu.ifi.dbs.elki.data.DoubleVector) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest) Test(org.junit.Test)

Example 18 with DoubleVector

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

the class KMeansCompareTest method testKMeansCompare.

/**
 * Run KMeans with fixed parameters and compare the result to a golden
 * standard.
 */
@Test
public void testKMeansCompare() {
    Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d-no-noise.ascii", 1000);
    Clustering<?> result = // 
    new ELKIBuilder<KMeansCompare<DoubleVector>>(KMeansCompare.class).with(KMeans.K_ID, // 
    5).with(KMeans.SEED_ID, // 
    7).build().run(db);
    testFMeasure(db, result, 0.998005);
    testClusterSizes(result, new int[] { 199, 200, 200, 200, 201 });
}
Also used : ELKIBuilder(de.lmu.ifi.dbs.elki.utilities.ELKIBuilder) Database(de.lmu.ifi.dbs.elki.database.Database) DoubleVector(de.lmu.ifi.dbs.elki.data.DoubleVector) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest) Test(org.junit.Test)

Example 19 with DoubleVector

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

the class KMeansHamerlyTest method testKMeansHamerly.

/**
 * Run KMeans with fixed parameters and compare the result to a golden
 * standard.
 */
@Test
public void testKMeansHamerly() {
    Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d-no-noise.ascii", 1000);
    Clustering<?> result = // 
    new ELKIBuilder<KMeansHamerly<DoubleVector>>(KMeansHamerly.class).with(KMeans.K_ID, // 
    5).with(KMeans.SEED_ID, // 
    7).build().run(db);
    testFMeasure(db, result, 0.998005);
    testClusterSizes(result, new int[] { 199, 200, 200, 200, 201 });
}
Also used : ELKIBuilder(de.lmu.ifi.dbs.elki.utilities.ELKIBuilder) Database(de.lmu.ifi.dbs.elki.database.Database) DoubleVector(de.lmu.ifi.dbs.elki.data.DoubleVector) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest) Test(org.junit.Test)

Example 20 with DoubleVector

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

the class ArffParser method setupBundleHeaders.

/**
 * Setup the headers for the object bundle.
 *
 * @param names Attribute names
 * @param targ Target columns
 * @param etyp ELKI type information
 * @param dimsize Number of dimensions in the individual types
 * @param bundle Output bundle
 * @param sparse Flag to create sparse vectors
 */
private void setupBundleHeaders(ArrayList<String> names, int[] targ, TypeInformation[] etyp, int[] dimsize, MultipleObjectsBundle bundle, boolean sparse) {
    for (int in = 0, out = 0; in < targ.length; out++) {
        int nin = in + 1;
        for (; nin < targ.length; nin++) {
            if (targ[nin] != targ[in]) {
                break;
            }
        }
        if (TypeUtil.NUMBER_VECTOR_FIELD.equals(etyp[out])) {
            String[] labels = new String[dimsize[out]];
            // Collect labels:
            for (int i = 0; i < dimsize[out]; i++) {
                labels[i] = names.get(out + i);
            }
            if (!sparse) {
                VectorFieldTypeInformation<DoubleVector> type = new VectorFieldTypeInformation<>(DoubleVector.FACTORY, dimsize[out], labels);
                bundle.appendColumn(type, new ArrayList<DoubleVector>());
            } else {
                VectorFieldTypeInformation<SparseDoubleVector> type = new VectorFieldTypeInformation<>(SparseDoubleVector.FACTORY, dimsize[out], labels);
                bundle.appendColumn(type, new ArrayList<SparseDoubleVector>());
            }
        } else if (TypeUtil.LABELLIST.equals(etyp[out])) {
            StringBuilder label = new StringBuilder(names.get(out));
            for (int i = 1; i < dimsize[out]; i++) {
                label.append(' ').append(names.get(out + i));
            }
            bundle.appendColumn(new SimpleTypeInformation<>(LabelList.class, label.toString()), new ArrayList<LabelList>());
        } else if (TypeUtil.EXTERNALID.equals(etyp[out])) {
            bundle.appendColumn(new SimpleTypeInformation<>(ExternalID.class, names.get(out)), new ArrayList<ExternalID>());
        } else if (TypeUtil.CLASSLABEL.equals(etyp[out])) {
            bundle.appendColumn(new SimpleTypeInformation<>(ClassLabel.class, names.get(out)), new ArrayList<ClassLabel>());
        } else {
            throw new AbortException("Unsupported type for column " + in + "->" + out + ": " + ((etyp[out] != null) ? etyp[out].toString() : "null"));
        }
        assert (out == bundle.metaLength() - 1);
        in = nin;
    }
}
Also used : ExternalID(de.lmu.ifi.dbs.elki.data.ExternalID) ArrayList(java.util.ArrayList) SimpleTypeInformation(de.lmu.ifi.dbs.elki.data.type.SimpleTypeInformation) SparseDoubleVector(de.lmu.ifi.dbs.elki.data.SparseDoubleVector) VectorFieldTypeInformation(de.lmu.ifi.dbs.elki.data.type.VectorFieldTypeInformation) DoubleVector(de.lmu.ifi.dbs.elki.data.DoubleVector) SparseDoubleVector(de.lmu.ifi.dbs.elki.data.SparseDoubleVector) AbortException(de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException)

Aggregations

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