SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIClassifier.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 1999-2009 Soeren Sonnenburg
8  * Written (W) 1999-2008 Gunnar Raetsch
9  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
12 #include <shogun/ui/SGInterface.h>
13 
14 #include <shogun/lib/config.h>
15 #include <shogun/io/SGIO.h>
16 
19 #include <shogun/labels/Labels.h>
20 
22 
23 #include <shogun/multiclass/KNN.h>
27 
28 #include <shogun/classifier/LDA.h>
29 #include <shogun/classifier/LPM.h>
32 
34 
35 #ifdef USE_SVMLIGHT
39 #endif //USE_SVMLIGHT
40 
50 
53 
59 
64 
66 
67 using namespace shogun;
68 
70 : CSGObject(), ui(ui_)
71 {
73  classifier=NULL;
75 
76  // Perceptron parameters
78  perceptron_maxiter=1000;
79 
80  // SVM parameters
81  svm_qpsize=41;
82  svm_bufsize=3000;
83  svm_max_qpsize=1000;
84  mkl_norm=1;
85  ent_lambda=0;
87  svm_C1=1;
88  svm_C2=1;
89  C_mkl=0;
91  svm_weight_epsilon=1e-5;
92  svm_epsilon=1e-5;
93  svm_tube_epsilon=1e-2;
94  svm_nu=0.5;
95  svm_use_shrinking = true ;
96 
97  svm_use_bias = true;
99  svm_use_linadd = true ;
100  svm_do_auc_maximization = false ;
101 
102  // KRR parameters
103  krr_tau=1;
104 
106 }
107 
109 {
112 }
113 
114 bool CGUIClassifier::new_classifier(char* name, int32_t d, int32_t from_d)
115 {
116  if (strcmp(name,"LIBSVM_ONECLASS")==0)
117  {
119  classifier = new CLibSVMOneClass();
120  SG_INFO("created SVMlibsvm object for oneclass\n")
121  }
122  else if (strcmp(name,"LIBSVM_MULTICLASS")==0)
123  {
126  SG_INFO("created SVMlibsvm object for multiclass\n")
127  }
128  else if (strcmp(name,"LIBSVM_NUMULTICLASS")==0)
129  {
131  classifier= new CMulticlassLibSVM(LIBSVM_NU_SVC);
132  SG_INFO("created SVMlibsvm object for multiclass\n")
133  }
134 #ifdef USE_SVMLIGHT
135  else if (strcmp(name,"SCATTERSVM_NO_BIAS_SVMLIGHT")==0)
136  {
139  SG_INFO("created ScatterSVM NO BIAS SVMLIGHT object\n")
140  }
141 #endif //USE_SVMLIGHT
142  else if (strcmp(name,"SCATTERSVM_NO_BIAS_LIBSVM")==0)
143  {
146  SG_INFO("created ScatterSVM NO BIAS LIBSVM object\n")
147  }
148  else if (strcmp(name,"SCATTERSVM_TESTRULE1")==0)
149  {
152  SG_INFO("created ScatterSVM TESTRULE1 object\n")
153  }
154  else if (strcmp(name,"SCATTERSVM_TESTRULE2")==0)
155  {
158  SG_INFO("created ScatterSVM TESTRULE2 object\n")
159  }
160  else if (strcmp(name,"LIBSVM_NU")==0)
161  {
163  classifier= new CLibSVM(LIBSVM_NU_SVC);
164  SG_INFO("created SVMlibsvm object\n")
165  }
166  else if (strcmp(name,"LIBSVM")==0)
167  {
169  classifier= new CLibSVM();
170  SG_INFO("created SVMlibsvm object\n")
171  }
172  else if (strcmp(name,"LARANK")==0)
173  {
175  classifier= new CLaRank();
176  SG_INFO("created LaRank object\n")
177  }
178 #ifdef USE_SVMLIGHT
179  else if ((strcmp(name,"LIGHT")==0) || (strcmp(name,"SVMLIGHT")==0))
180  {
182  classifier= new CSVMLight();
183  SG_INFO("created SVMLight object\n")
184  }
185  else if (strcmp(name,"SVMLIGHT_ONECLASS")==0)
186  {
189  SG_INFO("created SVMLightOneClass object\n")
190  }
191  else if (strcmp(name,"SVRLIGHT")==0)
192  {
194  classifier= new CSVRLight();
195  SG_INFO("created SVRLight object\n")
196  }
197 #endif //USE_SVMLIGHT
198  else if (strcmp(name,"GPBTSVM")==0)
199  {
201  classifier= new CGPBTSVM();
202  SG_INFO("created GPBT-SVM object\n")
203  }
204  else if (strcmp(name,"MPDSVM")==0)
205  {
207  classifier= new CMPDSVM();
208  SG_INFO("created MPD-SVM object\n")
209  }
210  else if (strcmp(name,"GNPPSVM")==0)
211  {
213  classifier= new CGNPPSVM();
214  SG_INFO("created GNPP-SVM object\n")
215  }
216  else if (strcmp(name,"GMNPSVM")==0)
217  {
219  classifier= new CGMNPSVM();
220  SG_INFO("created GMNP-SVM object\n")
221  }
222  else if (strcmp(name,"LIBSVR")==0)
223  {
225  classifier= new CLibSVR();
226  SG_INFO("created SVRlibsvm object\n")
227  }
228 #ifdef HAVE_LAPACK
229  else if (strcmp(name, "KERNELRIDGEREGRESSION")==0)
230  {
232  classifier=new CKernelRidgeRegression(krr_tau, ui->ui_kernel->get_kernel(),
233  ui->ui_labels->get_train_labels());
234  SG_INFO("created KernelRidgeRegression object %p\n", classifier)
235  }
236 #endif //HAVE_LAPACK
237  else if (strcmp(name,"PERCEPTRON")==0)
238  {
240  classifier= new CPerceptron();
241  SG_INFO("created Perceptron object\n")
242  }
243 #ifdef HAVE_LAPACK
244  else if (strncmp(name,"LIBLINEAR",9)==0)
245  {
247 
248  if (strcmp(name,"LIBLINEAR_L2R_LR")==0)
249  {
250  st=L2R_LR;
251  SG_INFO("created LibLinear l2 regularized logistic regression object\n")
252  }
253  else if (strcmp(name,"LIBLINEAR_L2R_L2LOSS_SVC_DUAL")==0)
254  {
256  SG_INFO("created LibLinear l2 regularized l2 loss SVM dual object\n")
257  }
258  else if (strcmp(name,"LIBLINEAR_L2R_L2LOSS_SVC")==0)
259  {
260  st=L2R_L2LOSS_SVC;
261  SG_INFO("created LibLinear l2 regularized l2 loss SVM primal object\n")
262  }
263  else if (strcmp(name,"LIBLINEAR_L1R_L2LOSS_SVC")==0)
264  {
265  st=L1R_L2LOSS_SVC;
266  SG_INFO("created LibLinear l1 regularized l2 loss SVM primal object\n")
267  }
268  else if (strcmp(name,"LIBLINEAR_L2R_L1LOSS_SVC_DUAL")==0)
269  {
271  SG_INFO("created LibLinear l2 regularized l1 loss dual SVM object\n")
272  }
273  else
274  SG_ERROR("unknown liblinear type\n")
275 
277  classifier= new CLibLinear(st);
278  ((CLibLinear*) classifier)->set_C(svm_C1, svm_C2);
279  ((CLibLinear*) classifier)->set_epsilon(svm_epsilon);
280  ((CLibLinear*) classifier)->set_bias_enabled(svm_use_bias);
281  }
282  else if (strcmp(name,"LDA")==0)
283  {
285  classifier= new CLDA();
286  SG_INFO("created LDA object\n")
287  }
288 #endif //HAVE_LAPACK
289 #ifdef USE_CPLEX
290  else if (strcmp(name,"LPM")==0)
291  {
293  classifier= new CLPM();
294  ((CLPM*) classifier)->set_C(svm_C1, svm_C2);
295  ((CLPM*) classifier)->set_epsilon(svm_epsilon);
296  ((CLPM*) classifier)->set_bias_enabled(svm_use_bias);
297  ((CLPM*) classifier)->set_max_train_time(max_train_time);
298  SG_INFO("created LPM object\n")
299  }
300  else if (strcmp(name,"LPBOOST")==0)
301  {
303  classifier= new CLPBoost();
304  ((CLPBoost*) classifier)->set_C(svm_C1, svm_C2);
305  ((CLPBoost*) classifier)->set_epsilon(svm_epsilon);
306  ((CLPBoost*) classifier)->set_bias_enabled(svm_use_bias);
307  ((CLPBoost*) classifier)->set_max_train_time(max_train_time);
308  SG_INFO("created LPBoost object\n")
309  }
310 #endif //USE_CPLEX
311  else if (strncmp(name,"KNN", strlen("KNN"))==0)
312  {
314  classifier= new CKNN();
315  SG_INFO("created KNN object\n")
316  }
317  else if (strncmp(name,"KMEANS", strlen("KMEANS"))==0)
318  {
320  classifier= new CKMeans();
321  SG_INFO("created KMeans object\n")
322  }
323  else if (strncmp(name,"HIERARCHICAL", strlen("HIERARCHICAL"))==0)
324  {
326  classifier= new CHierarchical();
327  SG_INFO("created Hierarchical clustering object\n")
328  }
329  else if (strcmp(name,"SVMLIN")==0)
330  {
332  classifier= new CSVMLin();
333  ((CSVMLin*) classifier)->set_C(svm_C1, svm_C2);
334  ((CSVMLin*) classifier)->set_epsilon(svm_epsilon);
335  ((CSVMLin*) classifier)->set_bias_enabled(svm_use_bias);
336  SG_INFO("created SVMLin object\n")
337  }
338  else if (strncmp(name,"WDSVMOCAS", strlen("WDSVMOCAS"))==0)
339  {
341  classifier= new CWDSVMOcas(SVM_OCAS);
342 
343  ((CWDSVMOcas*) classifier)->set_bias_enabled(svm_use_bias);
344  ((CWDSVMOcas*) classifier)->set_degree(d, from_d);
345  ((CWDSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
346  ((CWDSVMOcas*) classifier)->set_epsilon(svm_epsilon);
347  ((CWDSVMOcas*) classifier)->set_bufsize(svm_bufsize);
348  SG_INFO("created Weighted Degree Kernel SVM Ocas(OCAS) object of order %d (from order:%d)\n", d, from_d)
349  }
350  else if (strcmp(name,"SVMOCAS")==0)
351  {
353  classifier= new CSVMOcas(SVM_OCAS);
354 
355  ((CSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
356  ((CSVMOcas*) classifier)->set_epsilon(svm_epsilon);
357  ((CSVMOcas*) classifier)->set_bufsize(svm_bufsize);
358  ((CSVMOcas*) classifier)->set_bias_enabled(svm_use_bias);
359  SG_INFO("created SVM Ocas(OCAS) object\n")
360  }
361  else if (strcmp(name,"SVMSGD")==0)
362  {
364  classifier= new CSVMSGD(svm_C1);
365  ((CSVMSGD*) classifier)->set_bias_enabled(svm_use_bias);
366  SG_INFO("created SVM SGD object\n")
367  }
368  else if (strcmp(name,"SVMBMRM")==0 || (strcmp(name,"SVMPERF")==0))
369  {
371  classifier= new CSVMOcas(SVM_BMRM);
372 
373  ((CSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
374  ((CSVMOcas*) classifier)->set_epsilon(svm_epsilon);
375  ((CSVMOcas*) classifier)->set_bufsize(svm_bufsize);
376  ((CSVMOcas*) classifier)->set_bias_enabled(svm_use_bias);
377  SG_INFO("created SVM Ocas(BMRM/PERF) object\n")
378  }
379  else if (strcmp(name,"MKL_CLASSIFICATION")==0)
380  {
383  }
384  else if (strcmp(name,"MKL_ONECLASS")==0)
385  {
387  classifier= new CMKLOneClass();
388  }
389  else if (strcmp(name,"MKL_MULTICLASS")==0)
390  {
392  classifier= new CMKLMulticlass();
393  }
394  else if (strcmp(name,"MKL_REGRESSION")==0)
395  {
397  classifier= new CMKLRegression();
398  }
399  else
400  {
401  SG_ERROR("Unknown classifier %s.\n", name)
402  return false;
403  }
405 
406  return (classifier!=NULL);
407 }
408 
410 {
412  if (!mkl)
413  SG_ERROR("No MKL available.\n")
414 
415  CLabels* trainlabels=ui->ui_labels->get_train_labels();
416  if (!trainlabels)
417  SG_ERROR("No trainlabels available.\n")
418 
419  CKernel* kernel=ui->ui_kernel->get_kernel();
420  if (!kernel)
421  SG_ERROR("No kernel available.\n")
422 
423  bool success=ui->ui_kernel->init_kernel("TRAIN");
424 
425  if (!success || !ui->ui_kernel->is_initialized() || !kernel->has_features())
426  SG_ERROR("Kernel not initialized / no train features available.\n")
427 
428  int32_t num_vec=kernel->get_num_vec_lhs();
429  if (trainlabels->get_num_labels() != num_vec)
430  SG_ERROR("Number of train labels (%d) and training vectors (%d) differs!\n", trainlabels->get_num_labels(), num_vec)
431 
432  SG_INFO("Starting MC-MKL training on %ld vectors using C1=%lf C2=%lf epsilon=%lf\n", num_vec, svm_C1, svm_C2, svm_epsilon)
433 
435  mkl->set_mkl_norm(mkl_norm);
436  //mkl->set_max_num_mkliters(-1);
439  mkl->set_epsilon(svm_epsilon);
442  mkl->set_nu(svm_nu);
443  mkl->set_C(svm_C1);
444  mkl->set_qpsize(svm_qpsize);
448 
449  ((CKernelMulticlassMachine*) mkl)->set_labels(trainlabels);
450  ((CKernelMulticlassMachine*) mkl)->set_kernel(kernel);
451 
452  return mkl->train();
453 }
454 
456 {
457  CMKL* mkl= (CMKL*) classifier;
458  if (!mkl)
459  SG_ERROR("No SVM available.\n")
460 
461  bool oneclass=(mkl->get_classifier_type()==CT_LIBSVMONECLASS);
462  CLabels* trainlabels=NULL;
463  if(!oneclass)
464  trainlabels=ui->ui_labels->get_train_labels();
465  else
466  SG_INFO("Training one class mkl.\n")
467  if (!trainlabels && !oneclass)
468  SG_ERROR("No trainlabels available.\n")
469 
470  CKernel* kernel=ui->ui_kernel->get_kernel();
471  if (!kernel)
472  SG_ERROR("No kernel available.\n")
473 
474  bool success=ui->ui_kernel->init_kernel("TRAIN");
475  if (!success || !ui->ui_kernel->is_initialized() || !kernel->has_features())
476  SG_ERROR("Kernel not initialized.\n")
477 
478  int32_t num_vec=kernel->get_num_vec_lhs();
479  if (!oneclass && trainlabels->get_num_labels() != num_vec)
480  SG_ERROR("Number of train labels (%d) and training vectors (%d) differs!\n", trainlabels->get_num_labels(), num_vec)
481 
482  SG_INFO("Starting SVM training on %ld vectors using C1=%lf C2=%lf epsilon=%lf\n", num_vec, svm_C1, svm_C2, svm_epsilon)
483 
488  mkl->set_epsilon(svm_epsilon);
491  mkl->set_nu(svm_nu);
492  mkl->set_C(svm_C1, svm_C2);
493  mkl->set_qpsize(svm_qpsize);
498  mkl->set_mkl_norm(mkl_norm);
501  mkl->set_C_mkl(C_mkl);
503 
505  {
506  CAUCKernel* auc_kernel = new CAUCKernel(10, kernel);
507  CLabels* auc_labels= auc_kernel->setup_auc_maximization(trainlabels);
508  ((CKernelMachine*) mkl)->set_labels(auc_labels);
509  ((CKernelMachine*) mkl)->set_kernel(auc_kernel);
510  SG_UNREF(auc_labels);
511  }
512  else
513  {
514  if(!oneclass)
515  ((CKernelMachine*) mkl)->set_labels(trainlabels);
516  ((CKernelMachine*) mkl)->set_kernel(kernel);
517  }
518 
519  bool result=mkl->train();
520 
521  return result;
522 }
523 
525 {
527 
528  if (!classifier)
529  SG_ERROR("No SVM available.\n")
530 
531  bool oneclass=(type==CT_LIBSVMONECLASS);
532  CLabels* trainlabels=NULL;
533  if(!oneclass)
534  trainlabels=ui->ui_labels->get_train_labels();
535  else
536  SG_INFO("Training one class svm.\n")
537  if (!trainlabels && !oneclass)
538  SG_ERROR("No trainlabels available.\n")
539 
540  CKernel* kernel=ui->ui_kernel->get_kernel();
541  if (!kernel)
542  SG_ERROR("No kernel available.\n")
543 
544  bool success=ui->ui_kernel->init_kernel("TRAIN");
545 
546  if (!success || !ui->ui_kernel->is_initialized() || !kernel->has_features())
547  SG_ERROR("Kernel not initialized / no train features available.\n")
548 
549  int32_t num_vec=kernel->get_num_vec_lhs();
550  if (!oneclass && trainlabels->get_num_labels() != num_vec)
551  SG_ERROR("Number of train labels (%d) and training vectors (%d) differs!\n", trainlabels->get_num_labels(), num_vec)
552 
553  SG_INFO("Starting SVM training on %ld vectors using C1=%lf C2=%lf epsilon=%lf\n", num_vec, svm_C1, svm_C2, svm_epsilon)
554 
555  if (type==CT_LARANK || type==CT_GMNPSVM || type==CT_LIBSVMMULTICLASS)
556  {
560  svm->set_epsilon(svm_epsilon);
563  svm->set_nu(svm_nu);
564  svm->set_C(svm_C1);
565  svm->set_qpsize(svm_qpsize);
569  }
570  else
571  {
572  CSVM* svm = (CSVM*)classifier;
575  svm->set_epsilon(svm_epsilon);
578  svm->set_nu(svm_nu);
579  svm->set_C(svm_C1, svm_C2);
580  svm->set_qpsize(svm_qpsize);
584  }
585 
586  if (type==CT_MKLMULTICLASS)
587  {
588  ((CMKLMulticlass *)classifier)->set_mkl_epsilon(svm_weight_epsilon);
589  }
590 
592  {
593  CAUCKernel* auc_kernel = new CAUCKernel(10, kernel);
594  CLabels* auc_labels = auc_kernel->setup_auc_maximization(trainlabels);
595  ((CKernelMachine*)classifier)->set_labels(auc_labels);
596  ((CKernelMachine*)classifier)->set_kernel(auc_kernel);
597  SG_UNREF(auc_labels);
598  }
599  else
600  {
601  if (type==CT_LARANK || type==CT_GMNPSVM || type==CT_LIBSVMMULTICLASS)
602  {
603  ((CKernelMulticlassMachine*)classifier)->set_labels(trainlabels);
604  ((CKernelMulticlassMachine*)classifier)->set_kernel(kernel);
605  }
606  else
607  {
608  if(!oneclass)
609  ((CKernelMachine*)classifier)->set_labels(trainlabels);
610 
611  ((CKernelMachine*)classifier)->set_kernel(kernel);
612  }
613  }
614 
615  bool result = classifier->train();
616 
617  return result;
618 }
619 
620 bool CGUIClassifier::train_clustering(int32_t k, int32_t max_iter)
621 {
622  bool result=false;
623  CDistance* distance=ui->ui_distance->get_distance();
624 
625  if (!distance)
626  SG_ERROR("No distance available\n")
627 
628  if (!ui->ui_distance->init_distance("TRAIN"))
629  SG_ERROR("Initializing distance with train features failed.\n")
630 
631  ((CDistanceMachine*) classifier)->set_distance(distance);
632 
634  switch (type)
635  {
636  case CT_KMEANS:
637  {
638  ((CKMeans*) classifier)->set_k(k);
639  ((CKMeans*) classifier)->set_max_iter(max_iter);
640  result=((CKMeans*) classifier)->train();
641  break;
642  }
643  case CT_HIERARCHICAL:
644  {
645  ((CHierarchical*) classifier)->set_merges(k);
646  result=((CHierarchical*) classifier)->train();
647  break;
648  }
649  default:
650  SG_ERROR("Unknown clustering type %d\n", type)
651  }
652 
653  return result;
654 }
655 
657 {
658  CLabels* trainlabels=ui->ui_labels->get_train_labels();
659  CDistance* distance=ui->ui_distance->get_distance();
660 
661  bool result=false;
662 
663  if (trainlabels)
664  {
665  if (distance)
666  {
667  if (!ui->ui_distance->init_distance("TRAIN"))
668  SG_ERROR("Initializing distance with train features failed.\n")
669  ((CKNN*) classifier)->set_labels(trainlabels);
670  ((CKNN*) classifier)->set_distance(distance);
671  ((CKNN*) classifier)->set_k(k);
672  result=((CKNN*) classifier)->train();
673  }
674  else
675  SG_ERROR("No distance available.\n")
676  }
677  else
678  SG_ERROR("No labels available\n")
679 
680  return result;
681 }
682 
684 {
685 #ifdef HAVE_LAPACK
687  if (!krr)
688  SG_ERROR("No SVM available.\n")
689 
690  CLabels* trainlabels=NULL;
691  trainlabels=ui->ui_labels->get_train_labels();
692  if (!trainlabels)
693  SG_ERROR("No trainlabels available.\n")
694 
695  CKernel* kernel=ui->ui_kernel->get_kernel();
696  if (!kernel)
697  SG_ERROR("No kernel available.\n")
698 
699  bool success=ui->ui_kernel->init_kernel("TRAIN");
700 
701  if (!success || !ui->ui_kernel->is_initialized() || !kernel->has_features())
702  SG_ERROR("Kernel not initialized / no train features available.\n")
703 
704  int32_t num_vec=kernel->get_num_vec_lhs();
705  if (trainlabels->get_num_labels() != num_vec)
706  SG_ERROR("Number of train labels (%d) and training vectors (%d) differs!\n", trainlabels->get_num_labels(), num_vec)
707 
708 
709  // Set training labels and kernel
710  krr->set_labels(trainlabels);
711  krr->set_kernel(kernel);
712 
713  bool result=krr->train();
714  return result;
715 #else
716  return false;
717 #endif
718 }
719 
721 {
724  CFeatures* trainfeatures=ui->ui_features->get_train_features();
725  CLabels* trainlabels=ui->ui_labels->get_train_labels();
726  bool result=false;
727 
728  if (!trainfeatures)
729  SG_ERROR("No trainfeatures available.\n")
730 
731  if (!trainfeatures->has_property(FP_DOT))
732  SG_ERROR("Trainfeatures not based on DotFeatures.\n")
733 
734  if (!trainlabels)
735  SG_ERROR("No labels available\n")
736 
737  if (ctype==CT_PERCEPTRON)
738  {
739  ((CPerceptron*) classifier)->set_learn_rate(perceptron_learnrate);
740  ((CPerceptron*) classifier)->set_max_iter(perceptron_maxiter);
741  }
742 
743 #ifdef HAVE_LAPACK
744  if (ctype==CT_LDA)
745  {
746  if (trainfeatures->get_feature_type()!=F_DREAL ||
747  trainfeatures->get_feature_class()!=C_DENSE)
748  SG_ERROR("LDA requires train features of class SIMPLE type REAL.\n")
749  ((CLDA*) classifier)->set_gamma(gamma);
750  }
751 #endif
752 
753  if (ctype==CT_SVMOCAS)
754  ((CSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
755 #ifdef HAVE_LAPACK
756  else if (ctype==CT_LIBLINEAR)
757  ((CLibLinear*) classifier)->set_C(svm_C1, svm_C2);
758 #endif
759  else if (ctype==CT_SVMLIN)
760  ((CSVMLin*) classifier)->set_C(svm_C1, svm_C2);
761  else if (ctype==CT_SVMSGD)
762  ((CSVMSGD*) classifier)->set_C(svm_C1, svm_C2);
763  else if (ctype==CT_LPM || ctype==CT_LPBOOST)
764  {
765  if (trainfeatures->get_feature_class()!=C_SPARSE ||
766  trainfeatures->get_feature_type()!=F_DREAL)
767  SG_ERROR("LPM and LPBOOST require trainfeatures of class SPARSE type REAL.\n")
768  }
769 
770  ((CLinearMachine*) classifier)->set_labels(trainlabels);
771  ((CLinearMachine*) classifier)->set_features((CDenseFeatures<float64_t>*) trainfeatures);
772  result=((CLinearMachine*) classifier)->train();
773 
774  return result;
775 }
776 
778 {
779  CFeatures* trainfeatures=ui->ui_features->get_train_features();
780  CLabels* trainlabels=ui->ui_labels->get_train_labels();
781 
782  bool result=false;
783 
784  if (!trainfeatures)
785  SG_ERROR("No trainfeatures available.\n")
786 
787  if (trainfeatures->get_feature_class()!=C_STRING ||
788  trainfeatures->get_feature_type()!=F_BYTE )
789  SG_ERROR("Trainfeatures are not of class STRING type BYTE.\n")
790 
791  if (!trainlabels)
792  SG_ERROR("No labels available.\n")
793 
794  ((CWDSVMOcas*) classifier)->set_labels(trainlabels);
795  ((CWDSVMOcas*) classifier)->set_features((CStringFeatures<uint8_t>*) trainfeatures);
796  result=((CWDSVMOcas*) classifier)->train();
797 
798  return result;
799 }
800 
801 bool CGUIClassifier::load(char* filename, char* type)
802 {
803  bool result=false;
804 
805  if (new_classifier(type))
806  {
807  FILE* model_file=fopen(filename, "r");
808  CSerializableAsciiFile* ascii_file = new CSerializableAsciiFile(model_file,'r');
809 
810  if (ascii_file)
811  {
812  if (classifier && classifier->load_serializable(ascii_file))
813  {
814  SG_DEBUG("file successfully read.\n")
815  result=true;
816  }
817  else
818  SG_ERROR("SVM/Classifier creation/loading failed on file %s.\n", filename)
819 
820  delete ascii_file;
821  }
822  else
823  SG_ERROR("Opening file %s failed.\n", filename)
824 
825  return result;
826  }
827  else
828  SG_ERROR("Type %s of SVM/Classifier unknown.\n", type)
829 
830  return false;
831 }
832 
833 bool CGUIClassifier::save(char* param)
834 {
835  bool result=false;
836  param=SGIO::skip_spaces(param);
837 
838  if (classifier)
839  {
840  FILE* file=fopen(param, "w");
841  CSerializableAsciiFile* ascii_file = new CSerializableAsciiFile(file,'w');
842 
843  if ((!ascii_file) || (!classifier->save_serializable(ascii_file)))
844  printf("writing to file %s failed!\n", param);
845  else
846  {
847  printf("successfully written classifier into \"%s\" !\n", param);
848  result=true;
849  }
850 
851  if (ascii_file)
852  delete ascii_file;
853  }
854  else
855  SG_ERROR("create classifier first\n")
856 
857  return result;
858 }
859 
861  float64_t learnrate, int32_t maxiter)
862 {
863  if (learnrate<=0)
865  else
866  perceptron_learnrate=learnrate;
867 
868  if (maxiter<=0)
869  perceptron_maxiter=1000;
870  else
871  perceptron_maxiter=maxiter;
872  SG_INFO("Setting to perceptron parameters (learnrate %f and maxiter: %d\n", perceptron_learnrate, perceptron_maxiter)
873 
874  return true;
875 }
876 
878 {
879  if (epsilon<0)
880  svm_epsilon=1e-4;
881  else
883  SG_INFO("Set to svm_epsilon=%f.\n", svm_epsilon)
884 
885  return true;
886 }
887 
889 {
890  if (max>0)
891  {
892  max_train_time=max;
893  SG_INFO("Set to max_train_time=%f.\n", max_train_time)
894  }
895  else
896  SG_INFO("Disabling max_train_time.\n")
897 
898  return true;
899 }
900 
902 {
903  if (!classifier)
904  SG_ERROR("No regression method allocated\n")
905 
909  {
910  SG_ERROR("Underlying method not capable of SV-regression\n")
911  }
912 
913  if (tube_epsilon<0)
914  svm_tube_epsilon=1e-2;
915  svm_tube_epsilon=tube_epsilon;
916 
917  ((CSVM*) classifier)->set_tube_epsilon(svm_tube_epsilon);
918  SG_INFO("Set to svr_tube_epsilon=%f.\n", svm_tube_epsilon)
919 
920  return true;
921 }
922 
924 {
925  if (nu<0 || nu>1)
926  nu=0.5;
927 
928  svm_nu=nu;
929  SG_INFO("Set to nu=%f.\n", svm_nu)
930 
931  return true;
932 }
933 
935  float64_t weight_epsilon, float64_t C, float64_t norm)
936 {
937  if (weight_epsilon<0)
938  weight_epsilon=1e-4;
939  if (C<0)
940  C=0;
941  if (norm<0)
942  SG_ERROR("MKL norm >= 0\n")
943 
944  svm_weight_epsilon=weight_epsilon;
945  C_mkl=C;
946  mkl_norm=norm;
947 
948  SG_INFO("Set to weight_epsilon=%f.\n", svm_weight_epsilon)
949  SG_INFO("Set to C_mkl=%f.\n", C_mkl)
950  SG_INFO("Set to mkl_norm=%f.\n", mkl_norm)
951 
952  return true;
953 }
954 
956 {
957  if (lambda<0 || lambda>1)
958  SG_ERROR("0 <= ent_lambda <= 1\n")
959 
960  ent_lambda = lambda;
961  return true;
962 }
963 
965 {
966  if (mkl_bnorm<1)
967  SG_ERROR("1 <= mkl_block_norm <= inf\n")
968 
969  mkl_block_norm=mkl_bnorm;
970  return true;
971 }
972 
973 
975 {
976  if (C1<0)
977  svm_C1=1.0;
978  else
979  svm_C1=C1;
980 
981  if (C2<0)
982  svm_C2=svm_C1;
983  else
984  svm_C2=C2;
985 
986  SG_INFO("Set to C1=%f C2=%f.\n", svm_C1, svm_C2)
987 
988  return true;
989 }
990 
991 bool CGUIClassifier::set_svm_qpsize(int32_t qpsize)
992 {
993  if (qpsize<2)
994  svm_qpsize=41;
995  else
996  svm_qpsize=qpsize;
997  SG_INFO("Set qpsize to svm_qpsize=%d.\n", svm_qpsize)
998 
999  return true;
1000 }
1001 
1002 bool CGUIClassifier::set_svm_max_qpsize(int32_t max_qpsize)
1003 {
1004  if (max_qpsize<50)
1005  svm_max_qpsize=50;
1006  else
1007  svm_max_qpsize=max_qpsize;
1008  SG_INFO("Set max qpsize to svm_max_qpsize=%d.\n", svm_max_qpsize)
1009 
1010  return true;
1011 }
1012 
1013 bool CGUIClassifier::set_svm_bufsize(int32_t bufsize)
1014 {
1015  if (svm_bufsize<0)
1016  svm_bufsize=3000;
1017  else
1018  svm_bufsize=bufsize;
1019  SG_INFO("Set bufsize to svm_bufsize=%d.\n", svm_bufsize)
1020 
1021  return true ;
1022 }
1023 
1025 {
1026  svm_use_shrinking=enabled;
1027  if (svm_use_shrinking)
1028  SG_INFO("Enabling shrinking optimization.\n")
1029  else
1030  SG_INFO("Disabling shrinking optimization.\n")
1031 
1032  return true;
1033 }
1034 
1036 {
1037  svm_use_batch_computation=enabled;
1039  SG_INFO("Enabling batch computation.\n")
1040  else
1041  SG_INFO("Disabling batch computation.\n")
1042 
1043  return true;
1044 }
1045 
1047 {
1048  svm_use_linadd=enabled;
1049  if (svm_use_linadd)
1050  SG_INFO("Enabling LINADD optimization.\n")
1051  else
1052  SG_INFO("Disabling LINADD optimization.\n")
1053 
1054  return true;
1055 }
1056 
1058 {
1059  svm_use_bias=enabled;
1060  if (svm_use_bias)
1061  SG_INFO("Enabling svm bias.\n")
1062  else
1063  SG_INFO("Disabling svm bias.\n")
1064 
1065  return true;
1066 }
1067 
1069 {
1070  mkl_use_interleaved=enabled;
1071  if (mkl_use_interleaved)
1072  SG_INFO("Enabling mkl interleaved optimization.\n")
1073  else
1074  SG_INFO("Disabling mkl interleaved optimization.\n")
1075 
1076  return true;
1077 }
1078 
1080 {
1081  svm_do_auc_maximization=do_auc;
1082 
1084  SG_INFO("Enabling AUC maximization.\n")
1085  else
1086  SG_INFO("Disabling AUC maximization.\n")
1087 
1088  return true;
1089 }
1090 
1091 
1093 {
1095 
1096  switch (classifier->get_classifier_type())
1097  {
1098  case CT_LIGHT:
1099  case CT_LIGHTONECLASS:
1100  case CT_LIBSVM:
1101  case CT_SCATTERSVM:
1102  case CT_MPD:
1103  case CT_GPBT:
1104  case CT_CPLEXSVM:
1105  case CT_GMNPSVM:
1106  case CT_GNPPSVM:
1107  case CT_LIBSVR:
1108  case CT_LIBSVMMULTICLASS:
1109  case CT_LIBSVMONECLASS:
1110  case CT_SVRLIGHT:
1111  case CT_MKLCLASSIFICATION:
1112  case CT_MKLMULTICLASS:
1113  case CT_MKLREGRESSION:
1114  case CT_MKLONECLASS:
1116  return classify_kernelmachine();
1117  case CT_KNN:
1118  return classify_distancemachine();
1119  case CT_PERCEPTRON:
1120  case CT_LDA:
1121  return classify_linear();
1122  case CT_SVMLIN:
1123  case CT_SVMPERF:
1124  case CT_SVMOCAS:
1125  case CT_SVMSGD:
1126  case CT_LPM:
1127  case CT_LPBOOST:
1128  case CT_LIBLINEAR:
1129  return classify_linear();
1130  case CT_WDSVMOCAS:
1131  return classify_byte_linear();
1132  default:
1133  SG_ERROR("unknown classifier type\n")
1134  break;
1135  };
1136 
1137  return NULL;
1138 }
1139 
1141 {
1142  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1143  CFeatures* testfeatures=ui->ui_features->get_test_features();
1144 
1145  if (!classifier)
1146  SG_ERROR("No kernelmachine available.\n")
1147 
1148  bool success=true;
1149 
1150  REQUIRE(ui->ui_kernel->get_kernel(), "No kernel set");
1151  if (ui->ui_kernel->get_kernel()->get_kernel_type()!=K_CUSTOM)
1152  {
1153  if (ui->ui_kernel->get_kernel()->get_kernel_type()==K_COMBINED
1154  && ( !trainfeatures || !testfeatures ))
1155  {
1156  SG_DEBUG("skipping initialisation of combined kernel "
1157  "as train/test features are unavailable\n")
1158  }
1159  else
1160  {
1161  if (!trainfeatures)
1162  SG_ERROR("No training features available.\n")
1163  if (!testfeatures)
1164  SG_ERROR("No test features available.\n")
1165 
1166  success=ui->ui_kernel->init_kernel("TEST");
1167  }
1168  }
1169 
1170  if (!success || !ui->ui_kernel->is_initialized())
1171  SG_ERROR("Kernel not initialized.\n")
1172 
1174  if (type==CT_LARANK || type==CT_GMNPSVM || type==CT_LIBSVMMULTICLASS ||
1175  type==CT_MKLMULTICLASS)
1176  {
1178  kmcm->set_kernel(ui->ui_kernel->get_kernel());
1179  }
1180  else
1181  {
1183  km->set_kernel(ui->ui_kernel->get_kernel());
1185  }
1186 
1187  SG_INFO("Starting kernel machine testing.\n")
1188  return classifier->apply();
1189 }
1190 
1192  float64_t* &weights, int32_t &rows, int32_t &cols, float64_t*& bias,
1193  int32_t& brows, int32_t& bcols,
1194  int32_t idx) // which SVM for Multiclass
1195 {
1197 
1198  switch (classifier->get_classifier_type())
1199  {
1200  case CT_SCATTERSVM:
1201  case CT_GNPPSVM:
1202  case CT_LIBSVMMULTICLASS:
1203  case CT_LIGHT:
1204  case CT_LIGHTONECLASS:
1205  case CT_LIBSVM:
1206  case CT_MPD:
1207  case CT_GPBT:
1208  case CT_CPLEXSVM:
1209  case CT_GMNPSVM:
1210  case CT_LIBSVR:
1211  case CT_LIBSVMONECLASS:
1212  case CT_SVRLIGHT:
1213  case CT_MKLCLASSIFICATION:
1214  case CT_MKLREGRESSION:
1215  case CT_MKLONECLASS:
1216  case CT_MKLMULTICLASS:
1218  return get_svm(weights, rows, cols, bias, brows, bcols, idx);
1219  break;
1220  case CT_PERCEPTRON:
1221  case CT_LDA:
1222  case CT_LPM:
1223  case CT_LPBOOST:
1224  case CT_SVMOCAS:
1225  case CT_SVMSGD:
1226  case CT_SVMLIN:
1227  case CT_SVMPERF:
1228  case CT_LIBLINEAR:
1229  return get_linear(weights, rows, cols, bias, brows, bcols);
1230  break;
1231  case CT_KMEANS:
1232  case CT_HIERARCHICAL:
1233  return get_clustering(weights, rows, cols, bias, brows, bcols);
1234  break;
1235  case CT_KNN:
1236  SG_ERROR("not implemented")
1237  break;
1238  default:
1239  SG_ERROR("unknown classifier type\n")
1240  break;
1241  };
1242  return false;
1243 }
1244 
1245 
1247 {
1249  return ((CMulticlassSVM*) classifier)->get_num_machines();
1250 }
1251 
1253  float64_t* &weights, int32_t& rows, int32_t& cols, float64_t*& bias,
1254  int32_t& brows, int32_t& bcols, int32_t idx)
1255 {
1256  CSVM* svm=(CSVM*) classifier;
1257 
1258  if (idx>-1) // should be MulticlassSVM
1259  svm=((CMulticlassSVM*) svm)->get_svm(idx);
1260 
1261  if (svm)
1262  {
1263  brows=1;
1264  bcols=1;
1265  bias=SG_MALLOC(float64_t, 1);
1266  *bias=svm->get_bias();
1267 
1268  rows=svm->get_num_support_vectors();
1269  cols=2;
1270  weights=SG_MALLOC(float64_t, rows*cols);
1271 
1272  for (int32_t i=0; i<rows; i++)
1273  {
1274  weights[i]=svm->get_alpha(i);
1275  weights[i+rows]=svm->get_support_vector(i);
1276  }
1277 
1278  return true;
1279  }
1280 
1281  return false;
1282 }
1283 
1285  float64_t* &centers, int32_t& rows, int32_t& cols, float64_t*& radi,
1286  int32_t& brows, int32_t& bcols)
1287 {
1288  if (!classifier)
1289  return false;
1290 
1291  switch (classifier->get_classifier_type())
1292  {
1293  case CT_KMEANS:
1294  {
1295  CKMeans* clustering=(CKMeans*) classifier;
1296 
1297  bcols=1;
1298  SGVector<float64_t> r=clustering->get_radiuses();
1299  brows=r.vlen;
1300  radi=SG_MALLOC(float64_t, brows);
1301  memcpy(radi, r.vector, sizeof(float64_t)*brows);
1302 
1303  cols=1;
1304  SGMatrix<float64_t> c=clustering->get_cluster_centers();
1305  rows=c.num_rows;
1306  cols=c.num_cols;
1307  centers=SG_MALLOC(float64_t, rows*cols);
1308  memcpy(centers, c.matrix, sizeof(float64_t)*rows*cols);
1309  break;
1310  }
1311 
1312  case CT_HIERARCHICAL:
1313  {
1314  CHierarchical* clustering=(CHierarchical*) classifier;
1315 
1316  // radi == merge_distances, centers == pairs
1317  bcols=1;
1318  SGVector<float64_t> r=clustering->get_merge_distances();
1319  brows=r.vlen;
1320  radi=SG_MALLOC(float64_t, brows);
1321  memcpy(radi, r.vector, sizeof(float64_t)*brows);
1322 
1323  SGMatrix<int32_t> p=clustering->get_cluster_pairs();
1324  rows=p.num_rows;
1325  cols=p.num_cols;
1326  centers=SG_MALLOC(float64_t, rows*cols);
1327  for (int32_t i=0; i<rows*cols; i++)
1328  centers[i]=(float64_t) p.matrix[i];
1329 
1330  break;
1331  }
1332 
1333  default:
1334  SG_ERROR("internal error - unknown clustering type\n")
1335  }
1336 
1337  return true;
1338 }
1339 
1341  float64_t* &weights, int32_t& rows, int32_t& cols, float64_t*& bias,
1342  int32_t& brows, int32_t& bcols)
1343 {
1345 
1346  if (!linear)
1347  return false;
1348 
1349  bias=SG_MALLOC(float64_t, 1);
1350  *bias=linear->get_bias();
1351  brows=1;
1352  bcols=1;
1353 
1354  SGVector<float64_t> w=linear->get_w();
1355  cols=1;
1356  rows=w.vlen;
1357 
1358  weights= SG_MALLOC(float64_t, w.vlen);
1359  memcpy(weights, w.vector, sizeof(float64_t)*w.vlen);
1360 
1361  return true;
1362 }
1363 
1365 {
1366  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1367  CFeatures* testfeatures=ui->ui_features->get_test_features();
1368 
1369  if (!classifier)
1370  {
1371  SG_ERROR("no kernelmachine available\n")
1372  return NULL;
1373  }
1374  if (!trainfeatures)
1375  {
1376  SG_ERROR("no training features available\n")
1377  return NULL;
1378  }
1379 
1380  if (!testfeatures)
1381  {
1382  SG_ERROR("no test features available\n")
1383  return NULL;
1384  }
1385 
1386  bool success=ui->ui_distance->init_distance("TEST");
1387 
1388  if (!success || !ui->ui_distance->is_initialized())
1389  {
1390  SG_ERROR("distance not initialized\n")
1391  return NULL;
1392  }
1393 
1394  ((CDistanceMachine*) classifier)->set_distance(
1395  ui->ui_distance->get_distance());
1396  SG_INFO("starting distance machine testing\n")
1397  return classifier->apply();
1398 }
1399 
1400 
1402 {
1403  CFeatures* testfeatures=ui->ui_features->get_test_features();
1404 
1405  if (!classifier)
1406  {
1407  SG_ERROR("no classifier available\n")
1408  return NULL;
1409  }
1410  if (!testfeatures)
1411  {
1412  SG_ERROR("no test features available\n")
1413  return NULL;
1414  }
1415  if (!(testfeatures->has_property(FP_DOT)))
1416  {
1417  SG_ERROR("testfeatures not based on DotFeatures\n")
1418  return NULL;
1419  }
1420 
1421  ((CLinearMachine*) classifier)->set_features((CDotFeatures*) testfeatures);
1422  SG_INFO("starting linear classifier testing\n")
1423  return classifier->apply();
1424 }
1425 
1427 {
1428  CFeatures* testfeatures=ui->ui_features->get_test_features();
1429 
1430  if (!classifier)
1431  {
1432  SG_ERROR("no svm available\n")
1433  return NULL;
1434  }
1435  if (!testfeatures)
1436  {
1437  SG_ERROR("no test features available\n")
1438  return NULL;
1439  }
1440  if (testfeatures->get_feature_class() != C_STRING ||
1441  testfeatures->get_feature_type() != F_BYTE )
1442  {
1443  SG_ERROR("testfeatures not of class STRING type BYTE\n")
1444  return NULL;
1445  }
1446 
1447  ((CWDSVMOcas*) classifier)->set_features((CStringFeatures<uint8_t>*) testfeatures);
1448  SG_INFO("starting linear classifier testing\n")
1449  return classifier->apply();
1450 }
1451 
1453 {
1454  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1455  CFeatures* testfeatures=ui->ui_features->get_test_features();
1456 
1457  if (!classifier)
1458  {
1459  SG_ERROR("no svm available\n")
1460  return false;
1461  }
1462 
1463  if (!ui->ui_kernel->is_initialized())
1464  {
1465  SG_ERROR("kernel not initialized\n")
1466  return false;
1467  }
1468 
1469  if (!ui->ui_kernel->get_kernel() ||
1470  ui->ui_kernel->get_kernel()->get_kernel_type()!=K_CUSTOM)
1471  {
1472  if (!trainfeatures)
1473  {
1474  SG_ERROR("no training features available\n")
1475  return false;
1476  }
1477 
1478  if (!testfeatures)
1479  {
1480  SG_ERROR("no test features available\n")
1481  return false;
1482  }
1483  }
1484 
1485  ((CKernelMachine*) classifier)->set_kernel(
1486  ui->ui_kernel->get_kernel());
1487 
1488  result=((CKernelMachine*)classifier)->apply_one(idx);
1489  return true ;
1490 }
1491 
1492 
1494 {
1495 #ifdef HAVE_LAPACK
1496  krr_tau=tau;
1497  ((CKernelRidgeRegression*) classifier)->set_tau(krr_tau);
1498  SG_INFO("Set to krr_tau=%f.\n", krr_tau)
1499 
1500  return true;
1501 #else
1502  return false;
1503 #endif
1504 }
1505 
1506 bool CGUIClassifier::set_solver(char* solver)
1507 {
1508  ESolverType s=ST_AUTO;
1509 
1510  if (strncmp(solver,"NEWTON", 6)==0)
1511  {
1512  SG_INFO("Using NEWTON solver.\n")
1513  s=ST_NEWTON;
1514  }
1515  else if (strncmp(solver,"DIRECT", 6)==0)
1516  {
1517  SG_INFO("Using DIRECT solver\n")
1518  s=ST_DIRECT;
1519  }
1520  else if (strncmp(solver,"BLOCK_NORM", 9)==0)
1521  {
1522  SG_INFO("Using BLOCK_NORM solver\n")
1523  s=ST_BLOCK_NORM;
1524  }
1525  else if (strncmp(solver,"ELASTICNET", 10)==0)
1526  {
1527  SG_INFO("Using ELASTICNET solver\n")
1528  s=ST_ELASTICNET;
1529  }
1530  else if (strncmp(solver,"AUTO", 4)==0)
1531  {
1532  SG_INFO("Automagically determining solver.\n")
1533  s=ST_AUTO;
1534  }
1535 #ifdef USE_CPLEX
1536  else if (strncmp(solver, "CPLEX", 5)==0)
1537  {
1538  SG_INFO("USING CPLEX METHOD selected\n")
1539  s=ST_CPLEX;
1540  }
1541 #endif
1542 #ifdef USE_GLPK
1543  else if (strncmp(solver,"GLPK", 4)==0)
1544  {
1545  SG_INFO("Using GLPK solver\n")
1546  s=ST_GLPK;
1547  }
1548 #endif
1549  else
1550  SG_ERROR("Unknown solver type, %s (not compiled in?)\n", solver)
1551 
1552 
1553  solver_type=s;
1554  return true;
1555 }
1556 
1558 {
1559  if (strcmp(name,"LIBSVM_ONECLASS")==0)
1560  {
1563  SG_INFO("created SVMlibsvm object for oneclass\n")
1564  }
1565  else if (strcmp(name,"LIBSVM_NU")==0)
1566  {
1568  constraint_generator= new CLibSVM(LIBSVM_NU_SVC);
1569  SG_INFO("created SVMlibsvm object\n")
1570  }
1571  else if (strcmp(name,"LIBSVM")==0)
1572  {
1575  SG_INFO("created SVMlibsvm object\n")
1576  }
1577 #ifdef USE_SVMLIGHT
1578  else if ((strcmp(name,"LIGHT")==0) || (strcmp(name,"SVMLIGHT")==0))
1579  {
1582  SG_INFO("created SVMLight object\n")
1583  }
1584  else if (strcmp(name,"SVMLIGHT_ONECLASS")==0)
1585  {
1588  SG_INFO("created SVMLightOneClass object\n")
1589  }
1590  else if (strcmp(name,"SVRLIGHT")==0)
1591  {
1594  SG_INFO("created SVRLight object\n")
1595  }
1596 #endif //USE_SVMLIGHT
1597  else if (strcmp(name,"GPBTSVM")==0)
1598  {
1601  SG_INFO("created GPBT-SVM object\n")
1602  }
1603  else if (strcmp(name,"MPDSVM")==0)
1604  {
1607  SG_INFO("created MPD-SVM object\n")
1608  }
1609  else if (strcmp(name,"GNPPSVM")==0)
1610  {
1613  SG_INFO("created GNPP-SVM object\n")
1614  }
1615  else if (strcmp(name,"LIBSVR")==0)
1616  {
1619  SG_INFO("created SVRlibsvm object\n")
1620  }
1621  else
1622  {
1623  SG_ERROR("Unknown SV-classifier %s.\n", name)
1624  return false;
1625  }
1627 
1628  return (constraint_generator!=NULL);
1629 }

SHOGUN Machine Learning Toolbox - Documentation