Corrected a mistake in CHI2 kernel in line 354 and line 362 svm.cpp
Added new kernels to documentation
This commit is contained in:
parent
ddb0afbc44
commit
5484a41960
BIN
modules/ml/doc/pics/SVM_Comparison.png
Normal file
BIN
modules/ml/doc/pics/SVM_Comparison.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
@ -115,9 +115,13 @@ The constructors.
|
||||
|
||||
* **CvSVM::SIGMOID** Sigmoid kernel: :math:`K(x_i, x_j) = \tanh(\gamma x_i^T x_j + coef0)`.
|
||||
|
||||
* **CvSVM::CHI2** Exponential Chi2 kernel, similar to the RBF kernel: :math:`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`.
|
||||
|
||||
* **CvSVM::INTER** Histogram intersection kernel. A fast kernel. :math:`K(x_i, x_j) = min(x_i,x_j)`.
|
||||
|
||||
:param degree: Parameter ``degree`` of a kernel function (POLY).
|
||||
|
||||
:param gamma: Parameter :math:`\gamma` of a kernel function (POLY / RBF / SIGMOID).
|
||||
:param gamma: Parameter :math:`\gamma` of a kernel function (POLY / RBF / SIGMOID / CHI2).
|
||||
|
||||
:param coef0: Parameter ``coef0`` of a kernel function (POLY / SIGMOID).
|
||||
|
||||
@ -142,6 +146,10 @@ The default constructor initialize the structure with following values:
|
||||
term_crit = cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 1000, FLT_EPSILON );
|
||||
}
|
||||
|
||||
A comparison of different kernels on the following 2D test case with four classes. Four C_SVC SVMs have been trained (one against rest) with auto_train. Evaluation on three different kernels (CHI2, INTER, RBF). The color depicts the class with max score. Bright means max-score > 0, dark means max-score < 0.
|
||||
|
||||
.. image:: pics/SVM_Comparison.png
|
||||
|
||||
|
||||
|
||||
CvSVM
|
||||
|
@ -351,7 +351,7 @@ void CvSVMKernel::calc_chi2( int vcount, int var_count, const float** vecs,
|
||||
double chi2 = 0;
|
||||
for(k = 0 ; k < var_count; k++ )
|
||||
{
|
||||
double d = sample[k]*another[k];
|
||||
double d = sample[k]-another[k];
|
||||
double devisor = sample[k]+another[k];
|
||||
/// if devisor == 0, the Chi2 distance would be zero, but calculation would rise an error because of deviding by zero
|
||||
if (devisor != 0)
|
||||
@ -359,7 +359,7 @@ void CvSVMKernel::calc_chi2( int vcount, int var_count, const float** vecs,
|
||||
chi2 += d*d/devisor;
|
||||
}
|
||||
}
|
||||
results[j] = (Qfloat) (gamma*(1.0-2*chi2));
|
||||
results[j] = (Qfloat) (gamma*chi2);
|
||||
}
|
||||
if( vcount > 0 )
|
||||
cvExp( &R, &R );
|
||||
|
Loading…
Reference in New Issue
Block a user