提交 5484a419 编写于 作者: M Markus Schoeler

Corrected a mistake in CHI2 kernel in line 354 and line 362 svm.cpp

Added new kernels to documentation
上级 ddb0afbc
此差异由.gitattributes 抑制。
......@@ -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 );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册