use of de.lmu.ifi.dbs.elki.datasource.bundle.MultipleObjectsBundle in project elki by elki-project.
the class DropNaNFilter method filter.
@Override
public MultipleObjectsBundle filter(final MultipleObjectsBundle objects) {
if (LOG.isDebuggingFinest()) {
LOG.debugFinest("Removing records with NaN values.");
}
updateMeta(objects.meta());
MultipleObjectsBundle bundle = new MultipleObjectsBundle();
for (int j = 0; j < objects.metaLength(); j++) {
bundle.appendColumn(objects.meta(j), new ArrayList<>());
}
for (int i = 0; i < objects.dataLength(); i++) {
final Object[] row = objects.getRow(i);
boolean good = true;
for (int j = BitsUtil.nextSetBit(densecols, 0); j >= 0; j = BitsUtil.nextSetBit(densecols, j + 1)) {
NumberVector v = (NumberVector) row[j];
if (v == null) {
good = false;
break;
}
for (int d = 0; d < v.getDimensionality(); d++) {
if (Double.isNaN(v.doubleValue(d))) {
good = false;
break;
}
}
}
if (good) {
bundle.appendSimple(row);
}
}
return bundle;
}
use of de.lmu.ifi.dbs.elki.datasource.bundle.MultipleObjectsBundle in project elki by elki-project.
the class ReplaceNaNWithRandomFilter method filter.
@Override
public MultipleObjectsBundle filter(final MultipleObjectsBundle objects) {
if (LOG.isDebuggingFinest()) {
LOG.debugFinest("Removing records with NaN values.");
}
updateMeta(objects.meta());
MultipleObjectsBundle bundle = new MultipleObjectsBundle();
for (int j = 0; j < objects.metaLength(); j++) {
bundle.appendColumn(objects.meta(j), new ArrayList<>());
}
for (int i = 0; i < objects.dataLength(); i++) {
final Object[] row = objects.getRow(i);
for (int j = 0; j < densecols.length; j++) {
if (densecols[j] != null) {
NumberVector v = (NumberVector) row[j];
// replacement
double[] ro = null;
if (v != null) {
for (int d = 0; d < v.getDimensionality(); d++) {
if (Double.isNaN(v.doubleValue(d))) {
if (ro != null) {
ro = v.toArray();
}
ro[d] = dist.nextRandom();
}
}
}
row[j] = densecols[j].newNumberVector(ro);
}
}
bundle.appendSimple(row);
}
return bundle;
}
Aggregations