3

I want to use an SVM with the chi-squared kernel for an application I am writing, but it doesn't appear obvious how I can apply this.

I define the kernel as K(x_i, x_j) = exp( -1/A * D(x_i, x_j)), where A is a scaling parameter I can choose, and D(x_i, x_j) is the chi-squared distance between them.

How can this be done? It is a commonly used kernel in the computer vision literature, so it would be surprising if it was not possible.

Jim
  • 4,509
  • 16
  • 50
  • 80
  • Note really sure what you are after.. Is this in the right direction? http://scikit-learn.org/0.11/modules/kernel_approximation.html – SlimJim Sep 05 '12 at 21:46

2 Answers2

2

There is an implementation in OpenCV 3.0.0.0dev. See the link for details.

http://docs.opencv.org/master/modules/ml/doc/support_vector_machines.html

New Link: http://docs.opencv.org/3.0-beta/modules/ml/doc/support_vector_machines.html

Uzer
  • 3,054
  • 1
  • 17
  • 23
0

I don't think there is an option for chi-squared or an custom kernel in opencv.

So one option is to use a different SVM Library.

This is a modification of LIBSVM which supports an chi-squared kernel (a different one) and also precomputed kernels. But its targeted for the use with Matlab. So I am not sure how much it takes to make it work with C++.

Another option could be to use the linear SVM and transform your data to approximate the chi-squared kernel, if you want to stick to the opencv svm.

This answer might also give you some more hints.

Community
  • 1
  • 1
sietschie
  • 7,425
  • 3
  • 33
  • 54