The OpenCV docs give the following SVM kernel type example:
A comparison of different kernels on the following 2D test case with four classes. Four SVM::C_SVC SVMs have been trained (one against rest) with auto_train. Evaluation on three different kernels (SVM::CHI2, SVM::INTER, SVM::RBF). The color depicts the class with max score. Bright means max-score > 0, dark means max-score < 0.
Where can I find the sample code that generates this example?
Specifically, the SVM predict()
method presumably returns a label value and not a max-score. How can it return a max-score?
Note that the quote states that it uses SVM::C_SVC
which is a classification, not a regression, type.
You can get the score with 2-class SVM, and if you pass
RAW_OUTPUT
to predict:Then you need to train 4 different 2 class SVM, one against rest.
These are the result I get on these samples:
INTER with
trainAuto
CHI2 with
trainAuto
RBF with
train
(C = 0.1, gamma = 0.001
) (trainAuto
overfits in this case)Here is the code. You can enable
trainAuto
withAUTO_TRAIN_ENABLED
boolean variable, and you can set theKERNEL
as well as images dimensions, etc.