2

I'm trying to find the SVM kernel type and parameters that fits better my data. I'm using OpenCV on Python and I found the function cv2.SVM.train_auto to achieve this, but I didn't found a clear example of how to use it.

Could someone guide me to find the best kernel or give me an explanation of how to use cv2.SVM.train_auto?

1 Answer 1

1

I'm also looking for that information but you can have a look at the digits_adjust.py example, it uses train() instead of train_auto() and shows how to iterate on C and gamma parameters to try to find a best combination.

Interesting functions are:

...
def cross_validate(model_class, params, samples, labels, kfold = 3, pool = None):
...
    def adjust_SVM(self):
        Cs = np.logspace(0, 10, 15, base=2)
        gammas = np.logspace(-7, 4, 15, base=2)
...
            params = dict(C = Cs[i], gamma=gammas[j])
            score = cross_validate(SVM, params, samples, labels)
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.