Daniel@0: /************************************************************************/ Daniel@0: /* */ Daniel@0: /* kernel.h */ Daniel@0: /* */ Daniel@0: /* User defined kernel function. Feel free to plug in your own. */ Daniel@0: /* */ Daniel@0: /* Copyright: Thorsten Joachims */ Daniel@0: /* Date: 16.12.97 */ Daniel@0: /* */ Daniel@0: /************************************************************************/ Daniel@0: Daniel@0: /* KERNEL_PARM is defined in svm_common.h The field 'custom' is reserved for */ Daniel@0: /* parameters of the user defined kernel. You can also access and use */ Daniel@0: /* the parameters of the other kernels. Just replace the line Daniel@0: return((double)(1.0)); Daniel@0: with your own kernel. */ Daniel@0: Daniel@0: /* Example: The following computes the polynomial kernel. sprod_ss Daniel@0: computes the inner product between two sparse vectors. Daniel@0: Daniel@0: return((CFLOAT)pow(kernel_parm->coef_lin*sprod_ss(a->words,b->words) Daniel@0: +kernel_parm->coef_const,(double)kernel_parm->poly_degree)); Daniel@0: */ Daniel@0: Daniel@0: /* If you are implementing a kernel that is not based on a Daniel@0: feature/value representation, you might want to make use of the Daniel@0: field "userdefined" in SVECTOR. By default, this field will contain Daniel@0: whatever string you put behind a # sign in the example file. So, if Daniel@0: a line in your training file looks like Daniel@0: Daniel@0: -1 1:3 5:6 #abcdefg Daniel@0: Daniel@0: then the SVECTOR field "words" will contain the vector 1:3 5:6, and Daniel@0: "userdefined" will contain the string "abcdefg". */ Daniel@0: Daniel@0: double custom_kernel(KERNEL_PARM *kernel_parm, SVECTOR *a, SVECTOR *b) Daniel@0: /* plug in you favorite kernel */ Daniel@0: { Daniel@0: return((double)(1.0)); Daniel@0: }