Skip to content

ml_SVM_KernelTypes

mlclassOpenCV 5.0.0
import { ml_SVM_KernelTypes } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSConstructor or factory
CLASSml_SVM_KernelTypes
RETURN TYPEOwned native handle
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Native object: release it with using or delete(). Factories can return null; check before calling methods.

%SVM kernel type

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.
![image](pics/SVM_Comparison.png)

Constructors and members

static CUSTOM

Returned by SVM::getKernelType in case when custom kernel has been set

CUSTOM: ml_SVM_KernelTypesValue<-1>,

static LINEAR

Linear kernel. No mapping is done, linear discrimination (or regression) is done in the original feature space. It is the fastest option. K(x_i, x_j) = x_i^T x_j.

LINEAR: ml_SVM_KernelTypesValue<0>,

static POLY

Polynomial kernel: K(x_i, x_j) = (\gamma x_i^T x_j + coef0)^{degree}, \gamma > 0.

POLY: ml_SVM_KernelTypesValue<1>,

static RBF

Exponential Chi2 kernel, similar to the RBF kernel:

RBF: ml_SVM_KernelTypesValue<2>,

static SIGMOID

Sigmoid kernel: K(x_i, x_j) = \tanh(\gamma x_i^T x_j + coef0).

SIGMOID: ml_SVM_KernelTypesValue<3>,

static CHI2

Exponential Chi2 kernel, similar to the RBF kernel: K(x_i, x_j) = e^{-\gamma \chi^2(x_i,x_j)}, \chi^2(x_i,x_j) = (x_i-x_j)^2/(x_i+x_j), \gamma > 0.

CHI2: ml_SVM_KernelTypesValue<4>,

static INTER

Histogram intersection kernel. A fast kernel. K(x_i, x_j) = min(x_i,x_j).

INTER: ml_SVM_KernelTypesValue<5>

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.