Algorithm-SVMLight

 view release on metacpan or  search on metacpan

SVMLight.patch  view on Meta::CPAN

+  printf("\nSVM-light %s: Support Vector Machine, classification module     %s\n",SVMLIGHT_VERSION,SVMLIGHT_VERSION_DATE);
   copyright_notice();
   printf("   usage: svm_classify [options] example_file model_file output_file\n\n");
   printf("options: -h         -> this help\n");
diff -urb svm_light/svm_common.c svm_light-new/svm_common.c
--- svm_light/svm_common.c	2008-10-08 16:00:35.000000000 -0500
+++ svm_light-new/svm_common.c	2008-11-18 14:06:33.000000000 -0600
@@ -527,7 +527,7 @@
   }
   if ((modelfl = fopen (modelfile, "w")) == NULL)
   { perror (modelfile); exit (1); }
-  fprintf(modelfl,"SVM-light Version %s\n",VERSION);
+  fprintf(modelfl,"SVM-light Version %s\n",SVMLIGHT_VERSION);
   fprintf(modelfl,"%ld # kernel type\n",
 	  model->kernel_parm.kernel_type);
   fprintf(modelfl,"%ld # kernel parameter -d \n",
@@ -598,7 +598,7 @@
   { perror (modelfile); exit (1); }
 
   fscanf(modelfl,"SVM-light Version %s\n",version_buffer);
-  if(strcmp(version_buffer,VERSION)) {
+  if(strcmp(version_buffer,SVMLIGHT_VERSION)) {
     perror ("Version of model-file does not match version of svm_classify!"); 
     exit (1); 
   }
@@ -887,6 +887,103 @@
   return(alpha);
 }
 
+double costfunc(DOC **docs, double *rankvalue, long i, long j, LEARN_PARM *custom) {
+  return (docs[i]->costfactor+docs[j]->costfactor)/2.0;
+}
+

lib/Algorithm/SVMLight.xs  view on Meta::CPAN

  double *labels;
} corpus;

double ranking_callback(DOC **docs, double *rankvalue, long i, long j, LEARN_PARM *learn_parm) {
  dSP;
  SV *callback = (SV *) learn_parm->costfunccustom;
  int count;
  double result;

  /* Don't bother checking the type of 'callback' - it could be a CODE
   * reference or a string, and perl will throw its own error otherwise.
   */

  ENTER;
  SAVETMPS;

  PUSHMARK(SP);
  XPUSHs(sv_2mortal(newSVnv(rankvalue[i])));
  XPUSHs(sv_2mortal(newSVnv(rankvalue[j])));
  XPUSHs(sv_2mortal(newSVnv(docs[i]->costfactor)));
  XPUSHs(sv_2mortal(newSVnv(docs[j]->costfactor)));



( run in 0.596 second using v1.01-cache-2.11-cpan-65fba6d93b7 )