annotate toolboxes/SVM-light/src/kernel.h @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 /************************************************************************/
wolffd@0 2 /* */
wolffd@0 3 /* kernel.h */
wolffd@0 4 /* */
wolffd@0 5 /* User defined kernel function. Feel free to plug in your own. */
wolffd@0 6 /* */
wolffd@0 7 /* Copyright: Thorsten Joachims */
wolffd@0 8 /* Date: 16.12.97 */
wolffd@0 9 /* */
wolffd@0 10 /************************************************************************/
wolffd@0 11
wolffd@0 12 /* KERNEL_PARM is defined in svm_common.h The field 'custom' is reserved for */
wolffd@0 13 /* parameters of the user defined kernel. You can also access and use */
wolffd@0 14 /* the parameters of the other kernels. Just replace the line
wolffd@0 15 return((double)(1.0));
wolffd@0 16 with your own kernel. */
wolffd@0 17
wolffd@0 18 /* Example: The following computes the polynomial kernel. sprod_ss
wolffd@0 19 computes the inner product between two sparse vectors.
wolffd@0 20
wolffd@0 21 return((CFLOAT)pow(kernel_parm->coef_lin*sprod_ss(a->words,b->words)
wolffd@0 22 +kernel_parm->coef_const,(double)kernel_parm->poly_degree));
wolffd@0 23 */
wolffd@0 24
wolffd@0 25 /* If you are implementing a kernel that is not based on a
wolffd@0 26 feature/value representation, you might want to make use of the
wolffd@0 27 field "userdefined" in SVECTOR. By default, this field will contain
wolffd@0 28 whatever string you put behind a # sign in the example file. So, if
wolffd@0 29 a line in your training file looks like
wolffd@0 30
wolffd@0 31 -1 1:3 5:6 #abcdefg
wolffd@0 32
wolffd@0 33 then the SVECTOR field "words" will contain the vector 1:3 5:6, and
wolffd@0 34 "userdefined" will contain the string "abcdefg". */
wolffd@0 35
wolffd@0 36 double custom_kernel(KERNEL_PARM *kernel_parm, SVECTOR *a, SVECTOR *b)
wolffd@0 37 /* plug in you favorite kernel */
wolffd@0 38 {
wolffd@0 39 return((double)(1.0));
wolffd@0 40 }