use of de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.PreDeConNeighborPredicate.PreDeConModel in project elki by elki-project.
the class FourCNeighborPredicate method computeLocalModel.
@Override
protected PreDeConModel computeLocalModel(DBIDRef id, DoubleDBIDList neighbors, Relation<V> relation) {
mvSize.put(neighbors.size());
SortedEigenPairs epairs = pca.processIds(neighbors, relation).getEigenPairs();
int cordim = filter.filter(epairs.eigenValues());
PCAFilteredResult pcares = new PCAFilteredResult(epairs, cordim, settings.kappa, 1.);
double[][] m_hat = pcares.similarityMatrix();
double[] obj = relation.get(id).toArray();
// To save computing the square root below.
double sqeps = settings.epsilon * settings.epsilon;
HashSetModifiableDBIDs survivors = DBIDUtil.newHashSet(neighbors.size());
for (DBIDIter iter = neighbors.iter(); iter.valid(); iter.advance()) {
// Compute weighted / projected distance:
double[] diff = minusEquals(relation.get(iter).toArray(), obj);
double dist = transposeTimesTimes(diff, m_hat, diff);
if (dist <= sqeps) {
survivors.add(iter);
}
}
if (cordim <= settings.lambda) {
mvSize2.put(survivors.size());
}
mvCorDim.put(cordim);
return new PreDeConModel(cordim, survivors);
}
Aggregations