I have a distance matrix and I want to use that distance matrix when clustering my data.
I've read the ELKI documentation and it states that I can overwrite the distance
method when extending the AbstractNumberVectorDistanceFunction
class.
The distance
class however, returns the coordinates. So from coordinate x to coordinate y. This is troublesome because the distance matrix is filled only with distance values and we use the indexes to find the distance value from index x
to index y
. Here's the code from the documentation:
public class TutorialDistanceFunction extends AbstractNumberVectorDistanceFunction {
@Override
public double distance(NumberVector o1, NumberVector o2) {
double dx = o1.doubleValue(0) - o2.doubleValue(0);
double dy = o1.doubleValue(1) - o2.doubleValue(1);
return dx * dx + Math.abs(dy);
}
}
My question is how to correctly use the distance matrix when clustering with ELKI.