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

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