Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

knn

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

like image 794
Marco Avatar asked Jan 02 '12 10:01

Marco


1 Answers

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

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

like image 125
alf Avatar answered Oct 12 '22 11:10

alf