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