Algorithm-SVMLight
view release on metacpan or search on metacpan
SVMLight.patch view on Meta::CPAN
svm_learn_main.o: svm_learn_main.c svm_learn.h svm_common.h
- $(CC) -c $(CFLAGS) svm_learn_main.c -o svm_learn_main.o
+ $(CC) -c $(CFLAGS) $< -o $@
svm_classify.o: svm_classify.c svm_common.h kernel.h
- $(CC) -c $(CFLAGS) svm_classify.c -o svm_classify.o
-
-#loqo: pr_loqo/pr_loqo.o
+ $(CC) -c $(CFLAGS) $< -o $@
-#pr_loqo/pr_loqo.o: pr_loqo/pr_loqo.c
-# $(CC) -c $(CFLAGS) pr_loqo/pr_loqo.c -o pr_loqo/pr_loqo.o
+pr_loqo/pr_loqo.o: pr_loqo/pr_loqo.c
+ $(CC) -c $(CFLAGS) $< -o $@
diff -urb svm_light/svm_classify.c svm_light-new/svm_classify.c
--- svm_light/svm_classify.c 2008-10-08 14:05:54.000000000 -0500
+++ svm_light-new/svm_classify.c 2008-11-18 14:06:33.000000000 -0600
@@ -78,19 +78,20 @@
if((words[j]).wnum>model->totwords) /* are not larger than in */
(words[j]).wnum=0; /* model. Remove feature if */
} /* necessary. */
+ }
doc = create_example(-1,0,0,0.0,create_svector(words,comment,1.0));
t1=get_runtime();
+
+ if(model->kernel_parm.kernel_type == 0) { /* linear kernel */
dist=classify_example_linear(model,doc);
- runtime+=(get_runtime()-t1);
- free_example(doc,1);
}
else { /* non-linear kernel */
- doc = create_example(-1,0,0,0.0,create_svector(words,comment,1.0));
- t1=get_runtime();
dist=classify_example(model,doc);
+ }
+
runtime+=(get_runtime()-t1);
free_example(doc,1);
- }
+
if(dist>0) {
if(pred_format==0) { /* old weired output format */
fprintf(predfl,"%.8g:+1 %.8g:-1\n",dist,-dist);
@@ -183,7 +184,7 @@
void print_help(void)
{
- printf("\nSVM-light %s: Support Vector Machine, classification module %s\n",VERSION,VERSION_DATE);
+ 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;
+}
+
+void set_learning_defaults(LEARN_PARM *learn_parm, KERNEL_PARM *kernel_parm)
+{
+ learn_parm->type=CLASSIFICATION;
+ strcpy (learn_parm->predfile, "trans_predictions");
+ strcpy (learn_parm->alphafile, "");
+ learn_parm->biased_hyperplane=1;
+ learn_parm->sharedslack=0;
+ learn_parm->remove_inconsistent=0;
+ learn_parm->skip_final_opt_check=0;
+ learn_parm->svm_maxqpsize=10;
+ learn_parm->svm_newvarsinqp=0;
+ learn_parm->svm_iter_to_shrink=2;
+ learn_parm->maxiter=100000;
+ learn_parm->kernel_cache_size=40;
+ learn_parm->svm_c=0.0;
+ learn_parm->eps=0.1;
+ learn_parm->transduction_posratio=-1.0;
+ learn_parm->svm_costratio=1.0;
+ learn_parm->svm_costratio_unlab=1.0;
+ learn_parm->svm_unlabbound=1E-5;
+ learn_parm->epsilon_crit=0.001;
+ learn_parm->epsilon_a=1E-15;
+ learn_parm->compute_loo=0;
+ learn_parm->rho=1.0;
+ learn_parm->xa_depth=0;
+ learn_parm->costfunc=&costfunc;
+ learn_parm->costfunccustom=NULL;
+
+ kernel_parm->kernel_type=LINEAR;
+ kernel_parm->poly_degree=3;
+ kernel_parm->rbf_gamma=1.0;
+ kernel_parm->coef_lin=1;
+ kernel_parm->coef_const=1;
+ strcpy(kernel_parm->custom,"empty");
+}
+
+int check_learning_parms(LEARN_PARM *learn_parm, KERNEL_PARM *kernel_parm)
+{
+ if((learn_parm->skip_final_opt_check)
+ && (kernel_parm->kernel_type == LINEAR)) {
+ printf("\nIt does not make sense to skip the final optimality check for linear kernels.\n\n");
+ learn_parm->skip_final_opt_check=0;
+ }
+ if((learn_parm->skip_final_opt_check)
+ && (learn_parm->remove_inconsistent)) {
+ printf("\nIt is necessary to do the final optimality check when removing inconsistent \nexamples.\n");
+ return 0;
+ }
+ if((learn_parm->svm_maxqpsize<2)) {
+ printf("\nMaximum size of QP-subproblems not in valid range: %ld [2..]\n",learn_parm->svm_maxqpsize);
( run in 1.129 second using v1.01-cache-2.11-cpan-d7f47b0818f )