Search code examples
wekaknn

How can I use a different distance measure for the k-nearest neighbor in Java/Weka?


I am using the k-nearest neighbor classifier on weka (http://weka.sourceforge.net/doc.dev/weka/classifiers/lazy/IBk.html).

I suppose the Euclidean distance is the default distance function. How could I change that function and use the same class with my own distance function?

Thanks,

Marco


Solution

  • IBk.getNearestNeighbourSearchAlgorithm().setDistanceFunction() seems to be what you need.

    Check out http://weka.sourceforge.net/doc.dev/weka/core/DistanceFunction.html