SHOGUN  3.2.1
 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 #endif //HAVE_LAPACK
283 #ifdef HAVE_EIGEN3
284  else if (strcmp(name,"LDA")==0)
285  {
287  classifier= new CLDA();
288  SG_INFO("created LDA object\n")
289  }
290 #endif //HAVE_EIGEN3
291 #ifdef USE_CPLEX
292  else if (strcmp(name,"LPM")==0)
293  {
295  classifier= new CLPM();
296  ((CLPM*) classifier)->set_C(svm_C1, svm_C2);
297  ((CLPM*) classifier)->set_epsilon(svm_epsilon);
298  ((CLPM*) classifier)->set_bias_enabled(svm_use_bias);
299  ((CLPM*) classifier)->set_max_train_time(max_train_time);
300  SG_INFO("created LPM object\n")
301  }
302  else if (strcmp(name,"LPBOOST")==0)
303  {
305  classifier= new CLPBoost();
306  ((CLPBoost*) classifier)->set_C(svm_C1, svm_C2);
307  ((CLPBoost*) classifier)->set_epsilon(svm_epsilon);
308  ((CLPBoost*) classifier)->set_bias_enabled(svm_use_bias);
309  ((CLPBoost*) classifier)->set_max_train_time(max_train_time);
310  SG_INFO("created LPBoost object\n")
311  }
312 #endif //USE_CPLEX
313  else if (strncmp(name,"KNN", strlen("KNN"))==0)
314  {
316  classifier= new CKNN();
317  SG_INFO("created KNN object\n")
318  }
319  else if (strncmp(name,"KMEANS", strlen("KMEANS"))==0)
320  {
322  classifier= new CKMeans();
323  SG_INFO("created KMeans object\n")
324  }
325  else if (strncmp(name,"HIERARCHICAL", strlen("HIERARCHICAL"))==0)
326  {
328  classifier= new CHierarchical();
329  SG_INFO("created Hierarchical clustering object\n")
330  }
331  else if (strcmp(name,"SVMLIN")==0)
332  {
334  classifier= new CSVMLin();
335  ((CSVMLin*) classifier)->set_C(svm_C1, svm_C2);
336  ((CSVMLin*) classifier)->set_epsilon(svm_epsilon);
337  ((CSVMLin*) classifier)->set_bias_enabled(svm_use_bias);
338  SG_INFO("created SVMLin object\n")
339  }
340  else if (strncmp(name,"WDSVMOCAS", strlen("WDSVMOCAS"))==0)
341  {
343  classifier= new CWDSVMOcas(SVM_OCAS);
344 
345  ((CWDSVMOcas*) classifier)->set_bias_enabled(svm_use_bias);
346  ((CWDSVMOcas*) classifier)->set_degree(d, from_d);
347  ((CWDSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
348  ((CWDSVMOcas*) classifier)->set_epsilon(svm_epsilon);
349  ((CWDSVMOcas*) classifier)->set_bufsize(svm_bufsize);
350  SG_INFO("created Weighted Degree Kernel SVM Ocas(OCAS) object of order %d (from order:%d)\n", d, from_d)
351  }
352  else if (strcmp(name,"SVMOCAS")==0)
353  {
355  classifier= new CSVMOcas(SVM_OCAS);
356 
357  ((CSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
358  ((CSVMOcas*) classifier)->set_epsilon(svm_epsilon);
359  ((CSVMOcas*) classifier)->set_bufsize(svm_bufsize);
360  ((CSVMOcas*) classifier)->set_bias_enabled(svm_use_bias);
361  SG_INFO("created SVM Ocas(OCAS) object\n")
362  }
363  else if (strcmp(name,"SVMSGD")==0)
364  {
366  classifier= new CSVMSGD(svm_C1);
367  ((CSVMSGD*) classifier)->set_bias_enabled(svm_use_bias);
368  SG_INFO("created SVM SGD object\n")
369  }
370  else if (strcmp(name,"SVMBMRM")==0 || (strcmp(name,"SVMPERF")==0))
371  {
373  classifier= new CSVMOcas(SVM_BMRM);
374 
375  ((CSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
376  ((CSVMOcas*) classifier)->set_epsilon(svm_epsilon);
377  ((CSVMOcas*) classifier)->set_bufsize(svm_bufsize);
378  ((CSVMOcas*) classifier)->set_bias_enabled(svm_use_bias);
379  SG_INFO("created SVM Ocas(BMRM/PERF) object\n")
380  }
381  else if (strcmp(name,"MKL_CLASSIFICATION")==0)
382  {
385  }
386  else if (strcmp(name,"MKL_ONECLASS")==0)
387  {
389  classifier= new CMKLOneClass();
390  }
391  else if (strcmp(name,"MKL_MULTICLASS")==0)
392  {
394  classifier= new CMKLMulticlass();
395  }
396  else if (strcmp(name,"MKL_REGRESSION")==0)
397  {
399  classifier= new CMKLRegression();
400  }
401  else
402  {
403  SG_ERROR("Unknown classifier %s.\n", name)
404  return false;
405  }
407 
408  return (classifier!=NULL);
409 }
410 
412 {
414  if (!mkl)
415  SG_ERROR("No MKL available.\n")
416 
417  CLabels* trainlabels=ui->ui_labels->get_train_labels();
418  if (!trainlabels)
419  SG_ERROR("No trainlabels available.\n")
420 
421  CKernel* kernel=ui->ui_kernel->get_kernel();
422  if (!kernel)
423  SG_ERROR("No kernel available.\n")
424 
425  bool success=ui->ui_kernel->init_kernel("TRAIN");
426 
427  if (!success || !ui->ui_kernel->is_initialized() || !kernel->has_features())
428  SG_ERROR("Kernel not initialized / no train features available.\n")
429 
430  int32_t num_vec=kernel->get_num_vec_lhs();
431  if (trainlabels->get_num_labels() != num_vec)
432  SG_ERROR("Number of train labels (%d) and training vectors (%d) differs!\n", trainlabels->get_num_labels(), num_vec)
433 
434  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)
435 
437  mkl->set_mkl_norm(mkl_norm);
438  //mkl->set_max_num_mkliters(-1);
441  mkl->set_epsilon(svm_epsilon);
444  mkl->set_nu(svm_nu);
445  mkl->set_C(svm_C1);
446  mkl->set_qpsize(svm_qpsize);
450 
451  ((CKernelMulticlassMachine*) mkl)->set_labels(trainlabels);
452  ((CKernelMulticlassMachine*) mkl)->set_kernel(kernel);
453 
454  return mkl->train();
455 }
456 
458 {
459  CMKL* mkl= (CMKL*) classifier;
460  if (!mkl)
461  SG_ERROR("No SVM available.\n")
462 
463  bool oneclass=(mkl->get_classifier_type()==CT_LIBSVMONECLASS);
464  CLabels* trainlabels=NULL;
465  if(!oneclass)
466  trainlabels=ui->ui_labels->get_train_labels();
467  else
468  SG_INFO("Training one class mkl.\n")
469  if (!trainlabels && !oneclass)
470  SG_ERROR("No trainlabels available.\n")
471 
472  CKernel* kernel=ui->ui_kernel->get_kernel();
473  if (!kernel)
474  SG_ERROR("No kernel available.\n")
475 
476  bool success=ui->ui_kernel->init_kernel("TRAIN");
477  if (!success || !ui->ui_kernel->is_initialized() || !kernel->has_features())
478  SG_ERROR("Kernel not initialized.\n")
479 
480  int32_t num_vec=kernel->get_num_vec_lhs();
481  if (!oneclass && trainlabels->get_num_labels() != num_vec)
482  SG_ERROR("Number of train labels (%d) and training vectors (%d) differs!\n", trainlabels->get_num_labels(), num_vec)
483 
484  SG_INFO("Starting SVM training on %ld vectors using C1=%lf C2=%lf epsilon=%lf\n", num_vec, svm_C1, svm_C2, svm_epsilon)
485 
490  mkl->set_epsilon(svm_epsilon);
493  mkl->set_nu(svm_nu);
494  mkl->set_C(svm_C1, svm_C2);
495  mkl->set_qpsize(svm_qpsize);
500  mkl->set_mkl_norm(mkl_norm);
503  mkl->set_C_mkl(C_mkl);
505 
507  {
508  CAUCKernel* auc_kernel = new CAUCKernel(10, kernel);
509  CLabels* auc_labels= auc_kernel->setup_auc_maximization(trainlabels);
510  ((CKernelMachine*) mkl)->set_labels(auc_labels);
511  ((CKernelMachine*) mkl)->set_kernel(auc_kernel);
512  SG_UNREF(auc_labels);
513  }
514  else
515  {
516  if(!oneclass)
517  ((CKernelMachine*) mkl)->set_labels(trainlabels);
518  ((CKernelMachine*) mkl)->set_kernel(kernel);
519  }
520 
521  bool result=mkl->train();
522 
523  return result;
524 }
525 
527 {
529 
530  if (!classifier)
531  SG_ERROR("No SVM available.\n")
532 
533  bool oneclass=(type==CT_LIBSVMONECLASS);
534  CLabels* trainlabels=NULL;
535  if(!oneclass)
536  trainlabels=ui->ui_labels->get_train_labels();
537  else
538  SG_INFO("Training one class svm.\n")
539  if (!trainlabels && !oneclass)
540  SG_ERROR("No trainlabels available.\n")
541 
542  CKernel* kernel=ui->ui_kernel->get_kernel();
543  if (!kernel)
544  SG_ERROR("No kernel available.\n")
545 
546  bool success=ui->ui_kernel->init_kernel("TRAIN");
547 
548  if (!success || !ui->ui_kernel->is_initialized() || !kernel->has_features())
549  SG_ERROR("Kernel not initialized / no train features available.\n")
550 
551  int32_t num_vec=kernel->get_num_vec_lhs();
552  if (!oneclass && trainlabels->get_num_labels() != num_vec)
553  SG_ERROR("Number of train labels (%d) and training vectors (%d) differs!\n", trainlabels->get_num_labels(), num_vec)
554 
555  SG_INFO("Starting SVM training on %ld vectors using C1=%lf C2=%lf epsilon=%lf\n", num_vec, svm_C1, svm_C2, svm_epsilon)
556 
557  if (type==CT_LARANK || type==CT_GMNPSVM || type==CT_LIBSVMMULTICLASS)
558  {
562  svm->set_epsilon(svm_epsilon);
565  svm->set_nu(svm_nu);
566  svm->set_C(svm_C1);
567  svm->set_qpsize(svm_qpsize);
571  }
572  else
573  {
574  CSVM* svm = (CSVM*)classifier;
577  svm->set_epsilon(svm_epsilon);
580  svm->set_nu(svm_nu);
581  svm->set_C(svm_C1, svm_C2);
582  svm->set_qpsize(svm_qpsize);
586  }
587 
588  if (type==CT_MKLMULTICLASS)
589  {
590  ((CMKLMulticlass *)classifier)->set_mkl_epsilon(svm_weight_epsilon);
591  }
592 
594  {
595  CAUCKernel* auc_kernel = new CAUCKernel(10, kernel);
596  CLabels* auc_labels = auc_kernel->setup_auc_maximization(trainlabels);
597  ((CKernelMachine*)classifier)->set_labels(auc_labels);
598  ((CKernelMachine*)classifier)->set_kernel(auc_kernel);
599  SG_UNREF(auc_labels);
600  }
601  else
602  {
603  if (type==CT_LARANK || type==CT_GMNPSVM || type==CT_LIBSVMMULTICLASS)
604  {
605  ((CKernelMulticlassMachine*)classifier)->set_labels(trainlabels);
606  ((CKernelMulticlassMachine*)classifier)->set_kernel(kernel);
607  }
608  else
609  {
610  if(!oneclass)
611  ((CKernelMachine*)classifier)->set_labels(trainlabels);
612 
613  ((CKernelMachine*)classifier)->set_kernel(kernel);
614  }
615  }
616 
617  bool result = classifier->train();
618 
619  return result;
620 }
621 
622 bool CGUIClassifier::train_clustering(int32_t k, int32_t max_iter)
623 {
624  bool result=false;
625  CDistance* distance=ui->ui_distance->get_distance();
626 
627  if (!distance)
628  SG_ERROR("No distance available\n")
629 
630  if (!ui->ui_distance->init_distance("TRAIN"))
631  SG_ERROR("Initializing distance with train features failed.\n")
632 
633  ((CDistanceMachine*) classifier)->set_distance(distance);
634 
636  switch (type)
637  {
638  case CT_KMEANS:
639  {
640  ((CKMeans*) classifier)->set_k(k);
641  ((CKMeans*) classifier)->set_max_iter(max_iter);
642  result=((CKMeans*) classifier)->train();
643  break;
644  }
645  case CT_HIERARCHICAL:
646  {
647  ((CHierarchical*) classifier)->set_merges(k);
648  result=((CHierarchical*) classifier)->train();
649  break;
650  }
651  default:
652  SG_ERROR("Unknown clustering type %d\n", type)
653  }
654 
655  return result;
656 }
657 
659 {
660  CLabels* trainlabels=ui->ui_labels->get_train_labels();
661  CDistance* distance=ui->ui_distance->get_distance();
662 
663  bool result=false;
664 
665  if (trainlabels)
666  {
667  if (distance)
668  {
669  if (!ui->ui_distance->init_distance("TRAIN"))
670  SG_ERROR("Initializing distance with train features failed.\n")
671  ((CKNN*) classifier)->set_labels(trainlabels);
672  ((CKNN*) classifier)->set_distance(distance);
673  ((CKNN*) classifier)->set_k(k);
674  result=((CKNN*) classifier)->train();
675  }
676  else
677  SG_ERROR("No distance available.\n")
678  }
679  else
680  SG_ERROR("No labels available\n")
681 
682  return result;
683 }
684 
686 {
687 #ifdef HAVE_LAPACK
689  if (!krr)
690  SG_ERROR("No SVM available.\n")
691 
692  CLabels* trainlabels=NULL;
693  trainlabels=ui->ui_labels->get_train_labels();
694  if (!trainlabels)
695  SG_ERROR("No trainlabels available.\n")
696 
697  CKernel* kernel=ui->ui_kernel->get_kernel();
698  if (!kernel)
699  SG_ERROR("No kernel available.\n")
700 
701  bool success=ui->ui_kernel->init_kernel("TRAIN");
702 
703  if (!success || !ui->ui_kernel->is_initialized() || !kernel->has_features())
704  SG_ERROR("Kernel not initialized / no train features available.\n")
705 
706  int32_t num_vec=kernel->get_num_vec_lhs();
707  if (trainlabels->get_num_labels() != num_vec)
708  SG_ERROR("Number of train labels (%d) and training vectors (%d) differs!\n", trainlabels->get_num_labels(), num_vec)
709 
710 
711  // Set training labels and kernel
712  krr->set_labels(trainlabels);
713  krr->set_kernel(kernel);
714 
715  bool result=krr->train();
716  return result;
717 #else
718  return false;
719 #endif
720 }
721 
723 {
726  CFeatures* trainfeatures=ui->ui_features->get_train_features();
727  CLabels* trainlabels=ui->ui_labels->get_train_labels();
728  bool result=false;
729 
730  if (!trainfeatures)
731  SG_ERROR("No trainfeatures available.\n")
732 
733  if (!trainfeatures->has_property(FP_DOT))
734  SG_ERROR("Trainfeatures not based on DotFeatures.\n")
735 
736  if (!trainlabels)
737  SG_ERROR("No labels available\n")
738 
739  if (ctype==CT_PERCEPTRON)
740  {
741  ((CPerceptron*) classifier)->set_learn_rate(perceptron_learnrate);
742  ((CPerceptron*) classifier)->set_max_iter(perceptron_maxiter);
743  }
744 
745 #ifdef HAVE_EIGEN3
746  if (ctype==CT_LDA)
747  {
748  if (trainfeatures->get_feature_type()!=F_DREAL ||
749  trainfeatures->get_feature_class()!=C_DENSE)
750  SG_ERROR("LDA requires train features of class SIMPLE type REAL.\n")
751  ((CLDA*) classifier)->set_gamma(gamma);
752  }
753 #endif //HAVE_EIGEN3
754 
755  if (ctype==CT_SVMOCAS)
756  ((CSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
757 #ifdef HAVE_LAPACK
758  else if (ctype==CT_LIBLINEAR)
759  ((CLibLinear*) classifier)->set_C(svm_C1, svm_C2);
760 #endif
761  else if (ctype==CT_SVMLIN)
762  ((CSVMLin*) classifier)->set_C(svm_C1, svm_C2);
763  else if (ctype==CT_SVMSGD)
764  ((CSVMSGD*) classifier)->set_C(svm_C1, svm_C2);
765  else if (ctype==CT_LPM || ctype==CT_LPBOOST)
766  {
767  if (trainfeatures->get_feature_class()!=C_SPARSE ||
768  trainfeatures->get_feature_type()!=F_DREAL)
769  SG_ERROR("LPM and LPBOOST require trainfeatures of class SPARSE type REAL.\n")
770  }
771 
772  ((CLinearMachine*) classifier)->set_labels(trainlabels);
773  ((CLinearMachine*) classifier)->set_features((CDenseFeatures<float64_t>*) trainfeatures);
774  result=((CLinearMachine*) classifier)->train();
775 
776  return result;
777 }
778 
780 {
781  CFeatures* trainfeatures=ui->ui_features->get_train_features();
782  CLabels* trainlabels=ui->ui_labels->get_train_labels();
783 
784  bool result=false;
785 
786  if (!trainfeatures)
787  SG_ERROR("No trainfeatures available.\n")
788 
789  if (trainfeatures->get_feature_class()!=C_STRING ||
790  trainfeatures->get_feature_type()!=F_BYTE )
791  SG_ERROR("Trainfeatures are not of class STRING type BYTE.\n")
792 
793  if (!trainlabels)
794  SG_ERROR("No labels available.\n")
795 
796  ((CWDSVMOcas*) classifier)->set_labels(trainlabels);
797  ((CWDSVMOcas*) classifier)->set_features((CStringFeatures<uint8_t>*) trainfeatures);
798  result=((CWDSVMOcas*) classifier)->train();
799 
800  return result;
801 }
802 
803 bool CGUIClassifier::load(char* filename, char* type)
804 {
805  bool result=false;
806 
807  if (new_classifier(type))
808  {
809  FILE* model_file=fopen(filename, "r");
810  REQUIRE(model_file != NULL, "SVM/Classifier loading failed on file %s.\n", filename);
811 
812  CSerializableAsciiFile* ascii_file = new CSerializableAsciiFile(model_file,'r');
813 
814  if (ascii_file)
815  {
816  if (classifier && classifier->load_serializable(ascii_file))
817  {
818  SG_DEBUG("file successfully read.\n")
819  result=true;
820  }
821  else
822  SG_ERROR("SVM/Classifier creation/loading failed on file %s.\n", filename)
823 
824  delete ascii_file;
825  }
826  else
827  SG_ERROR("Opening file %s failed.\n", filename)
828 
829  return result;
830  }
831  else
832  SG_ERROR("Type %s of SVM/Classifier unknown.\n", type)
833 
834  return false;
835 }
836 
837 bool CGUIClassifier::save(char* param)
838 {
839  bool result=false;
840  param=SGIO::skip_spaces(param);
841 
842  if (classifier)
843  {
844  FILE* file=fopen(param, "w");
845  CSerializableAsciiFile* ascii_file = new CSerializableAsciiFile(file,'w');
846 
847  if ((!ascii_file) || (!classifier->save_serializable(ascii_file)))
848  printf("writing to file %s failed!\n", param);
849  else
850  {
851  printf("successfully written classifier into \"%s\" !\n", param);
852  result=true;
853  }
854 
855  if (ascii_file)
856  delete ascii_file;
857  }
858  else
859  SG_ERROR("create classifier first\n")
860 
861  return result;
862 }
863 
865  float64_t learnrate, int32_t maxiter)
866 {
867  if (learnrate<=0)
869  else
870  perceptron_learnrate=learnrate;
871 
872  if (maxiter<=0)
873  perceptron_maxiter=1000;
874  else
875  perceptron_maxiter=maxiter;
876  SG_INFO("Setting to perceptron parameters (learnrate %f and maxiter: %d\n", perceptron_learnrate, perceptron_maxiter)
877 
878  return true;
879 }
880 
882 {
883  if (epsilon<0)
884  svm_epsilon=1e-4;
885  else
887  SG_INFO("Set to svm_epsilon=%f.\n", svm_epsilon)
888 
889  return true;
890 }
891 
893 {
894  if (max>0)
895  {
897  SG_INFO("Set to max_train_time=%f.\n", max_train_time)
898  }
899  else
900  SG_INFO("Disabling max_train_time.\n")
901 
902  return true;
903 }
904 
906 {
907  if (!classifier)
908  SG_ERROR("No regression method allocated\n")
909 
913  {
914  SG_ERROR("Underlying method not capable of SV-regression\n")
915  }
916 
917  if (tube_epsilon<0)
918  svm_tube_epsilon=1e-2;
919  svm_tube_epsilon=tube_epsilon;
920 
921  ((CSVM*) classifier)->set_tube_epsilon(svm_tube_epsilon);
922  SG_INFO("Set to svr_tube_epsilon=%f.\n", svm_tube_epsilon)
923 
924  return true;
925 }
926 
928 {
929  if (nu<0 || nu>1)
930  nu=0.5;
931 
932  svm_nu=nu;
933  SG_INFO("Set to nu=%f.\n", svm_nu)
934 
935  return true;
936 }
937 
939  float64_t weight_epsilon, float64_t C, float64_t norm)
940 {
941  if (weight_epsilon<0)
942  weight_epsilon=1e-4;
943  if (C<0)
944  C=0;
945  if (norm<0)
946  SG_ERROR("MKL norm >= 0\n")
947 
948  svm_weight_epsilon=weight_epsilon;
949  C_mkl=C;
950  mkl_norm=norm;
951 
952  SG_INFO("Set to weight_epsilon=%f.\n", svm_weight_epsilon)
953  SG_INFO("Set to C_mkl=%f.\n", C_mkl)
954  SG_INFO("Set to mkl_norm=%f.\n", mkl_norm)
955 
956  return true;
957 }
958 
960 {
961  if (lambda<0 || lambda>1)
962  SG_ERROR("0 <= ent_lambda <= 1\n")
963 
964  ent_lambda = lambda;
965  return true;
966 }
967 
969 {
970  if (mkl_bnorm<1)
971  SG_ERROR("1 <= mkl_block_norm <= inf\n")
972 
973  mkl_block_norm=mkl_bnorm;
974  return true;
975 }
976 
977 
979 {
980  if (C1<0)
981  svm_C1=1.0;
982  else
983  svm_C1=C1;
984 
985  if (C2<0)
986  svm_C2=svm_C1;
987  else
988  svm_C2=C2;
989 
990  SG_INFO("Set to C1=%f C2=%f.\n", svm_C1, svm_C2)
991 
992  return true;
993 }
994 
995 bool CGUIClassifier::set_svm_qpsize(int32_t qpsize)
996 {
997  if (qpsize<2)
998  svm_qpsize=41;
999  else
1000  svm_qpsize=qpsize;
1001  SG_INFO("Set qpsize to svm_qpsize=%d.\n", svm_qpsize)
1002 
1003  return true;
1004 }
1005 
1006 bool CGUIClassifier::set_svm_max_qpsize(int32_t max_qpsize)
1007 {
1008  if (max_qpsize<50)
1009  svm_max_qpsize=50;
1010  else
1011  svm_max_qpsize=max_qpsize;
1012  SG_INFO("Set max qpsize to svm_max_qpsize=%d.\n", svm_max_qpsize)
1013 
1014  return true;
1015 }
1016 
1017 bool CGUIClassifier::set_svm_bufsize(int32_t bufsize)
1018 {
1019  if (svm_bufsize<0)
1020  svm_bufsize=3000;
1021  else
1022  svm_bufsize=bufsize;
1023  SG_INFO("Set bufsize to svm_bufsize=%d.\n", svm_bufsize)
1024 
1025  return true ;
1026 }
1027 
1029 {
1030  svm_use_shrinking=enabled;
1031  if (svm_use_shrinking)
1032  SG_INFO("Enabling shrinking optimization.\n")
1033  else
1034  SG_INFO("Disabling shrinking optimization.\n")
1035 
1036  return true;
1037 }
1038 
1040 {
1041  svm_use_batch_computation=enabled;
1043  SG_INFO("Enabling batch computation.\n")
1044  else
1045  SG_INFO("Disabling batch computation.\n")
1046 
1047  return true;
1048 }
1049 
1051 {
1052  svm_use_linadd=enabled;
1053  if (svm_use_linadd)
1054  SG_INFO("Enabling LINADD optimization.\n")
1055  else
1056  SG_INFO("Disabling LINADD optimization.\n")
1057 
1058  return true;
1059 }
1060 
1062 {
1063  svm_use_bias=enabled;
1064  if (svm_use_bias)
1065  SG_INFO("Enabling svm bias.\n")
1066  else
1067  SG_INFO("Disabling svm bias.\n")
1068 
1069  return true;
1070 }
1071 
1073 {
1074  mkl_use_interleaved=enabled;
1075  if (mkl_use_interleaved)
1076  SG_INFO("Enabling mkl interleaved optimization.\n")
1077  else
1078  SG_INFO("Disabling mkl interleaved optimization.\n")
1079 
1080  return true;
1081 }
1082 
1084 {
1085  svm_do_auc_maximization=do_auc;
1086 
1088  SG_INFO("Enabling AUC maximization.\n")
1089  else
1090  SG_INFO("Disabling AUC maximization.\n")
1091 
1092  return true;
1093 }
1094 
1095 
1097 {
1099 
1100  switch (classifier->get_classifier_type())
1101  {
1102  case CT_LIGHT:
1103  case CT_LIGHTONECLASS:
1104  case CT_LIBSVM:
1105  case CT_SCATTERSVM:
1106  case CT_MPD:
1107  case CT_GPBT:
1108  case CT_CPLEXSVM:
1109  case CT_GMNPSVM:
1110  case CT_GNPPSVM:
1111  case CT_LIBSVR:
1112  case CT_LIBSVMMULTICLASS:
1113  case CT_LIBSVMONECLASS:
1114  case CT_SVRLIGHT:
1115  case CT_MKLCLASSIFICATION:
1116  case CT_MKLMULTICLASS:
1117  case CT_MKLREGRESSION:
1118  case CT_MKLONECLASS:
1120  return classify_kernelmachine();
1121  case CT_KNN:
1122  return classify_distancemachine();
1123  case CT_PERCEPTRON:
1124  case CT_LDA:
1125  return classify_linear();
1126  case CT_SVMLIN:
1127  case CT_SVMPERF:
1128  case CT_SVMOCAS:
1129  case CT_SVMSGD:
1130  case CT_LPM:
1131  case CT_LPBOOST:
1132  case CT_LIBLINEAR:
1133  return classify_linear();
1134  case CT_WDSVMOCAS:
1135  return classify_byte_linear();
1136  default:
1137  SG_ERROR("unknown classifier type\n")
1138  break;
1139  };
1140 
1141  return NULL;
1142 }
1143 
1145 {
1146  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1147  CFeatures* testfeatures=ui->ui_features->get_test_features();
1148 
1149  if (!classifier)
1150  SG_ERROR("No kernelmachine available.\n")
1151 
1152  bool success=true;
1153 
1154  REQUIRE(ui->ui_kernel->get_kernel(), "No kernel set");
1155  if (ui->ui_kernel->get_kernel()->get_kernel_type()!=K_CUSTOM)
1156  {
1157  if (ui->ui_kernel->get_kernel()->get_kernel_type()==K_COMBINED
1158  && ( !trainfeatures || !testfeatures ))
1159  {
1160  SG_DEBUG("skipping initialisation of combined kernel "
1161  "as train/test features are unavailable\n")
1162  }
1163  else
1164  {
1165  if (!trainfeatures)
1166  SG_ERROR("No training features available.\n")
1167  if (!testfeatures)
1168  SG_ERROR("No test features available.\n")
1169 
1170  success=ui->ui_kernel->init_kernel("TEST");
1171  }
1172  }
1173 
1174  if (!success || !ui->ui_kernel->is_initialized())
1175  SG_ERROR("Kernel not initialized.\n")
1176 
1178  if (type==CT_LARANK || type==CT_GMNPSVM || type==CT_LIBSVMMULTICLASS ||
1179  type==CT_MKLMULTICLASS)
1180  {
1182  kmcm->set_kernel(ui->ui_kernel->get_kernel());
1183  }
1184  else
1185  {
1187  km->set_kernel(ui->ui_kernel->get_kernel());
1189  }
1190 
1191  SG_INFO("Starting kernel machine testing.\n")
1192  return classifier->apply();
1193 }
1194 
1196  float64_t* &weights, int32_t &rows, int32_t &cols, float64_t*& bias,
1197  int32_t& brows, int32_t& bcols,
1198  int32_t idx) // which SVM for Multiclass
1199 {
1201 
1202  switch (classifier->get_classifier_type())
1203  {
1204  case CT_SCATTERSVM:
1205  case CT_GNPPSVM:
1206  case CT_LIBSVMMULTICLASS:
1207  case CT_LIGHT:
1208  case CT_LIGHTONECLASS:
1209  case CT_LIBSVM:
1210  case CT_MPD:
1211  case CT_GPBT:
1212  case CT_CPLEXSVM:
1213  case CT_GMNPSVM:
1214  case CT_LIBSVR:
1215  case CT_LIBSVMONECLASS:
1216  case CT_SVRLIGHT:
1217  case CT_MKLCLASSIFICATION:
1218  case CT_MKLREGRESSION:
1219  case CT_MKLONECLASS:
1220  case CT_MKLMULTICLASS:
1222  return get_svm(weights, rows, cols, bias, brows, bcols, idx);
1223  break;
1224  case CT_PERCEPTRON:
1225  case CT_LDA:
1226  case CT_LPM:
1227  case CT_LPBOOST:
1228  case CT_SVMOCAS:
1229  case CT_SVMSGD:
1230  case CT_SVMLIN:
1231  case CT_SVMPERF:
1232  case CT_LIBLINEAR:
1233  return get_linear(weights, rows, cols, bias, brows, bcols);
1234  break;
1235  case CT_KMEANS:
1236  case CT_HIERARCHICAL:
1237  return get_clustering(weights, rows, cols, bias, brows, bcols);
1238  break;
1239  case CT_KNN:
1240  SG_ERROR("not implemented")
1241  break;
1242  default:
1243  SG_ERROR("unknown classifier type\n")
1244  break;
1245  };
1246  return false;
1247 }
1248 
1249 
1251 {
1253  return ((CMulticlassSVM*) classifier)->get_num_machines();
1254 }
1255 
1257  float64_t* &weights, int32_t& rows, int32_t& cols, float64_t*& bias,
1258  int32_t& brows, int32_t& bcols, int32_t idx)
1259 {
1260  CSVM* svm=(CSVM*) classifier;
1261 
1262  if (idx>-1) // should be MulticlassSVM
1263  svm=((CMulticlassSVM*) svm)->get_svm(idx);
1264 
1265  if (svm)
1266  {
1267  brows=1;
1268  bcols=1;
1269  bias=SG_MALLOC(float64_t, 1);
1270  *bias=svm->get_bias();
1271 
1272  rows=svm->get_num_support_vectors();
1273  cols=2;
1274  weights=SG_MALLOC(float64_t, rows*cols);
1275 
1276  for (int32_t i=0; i<rows; i++)
1277  {
1278  weights[i]=svm->get_alpha(i);
1279  weights[i+rows]=svm->get_support_vector(i);
1280  }
1281 
1282  return true;
1283  }
1284 
1285  return false;
1286 }
1287 
1289  float64_t* &centers, int32_t& rows, int32_t& cols, float64_t*& radi,
1290  int32_t& brows, int32_t& bcols)
1291 {
1292  if (!classifier)
1293  return false;
1294 
1295  switch (classifier->get_classifier_type())
1296  {
1297  case CT_KMEANS:
1298  {
1299  CKMeans* clustering=(CKMeans*) classifier;
1300 
1301  bcols=1;
1302  SGVector<float64_t> r=clustering->get_radiuses();
1303  brows=r.vlen;
1304  radi=SG_MALLOC(float64_t, brows);
1305  memcpy(radi, r.vector, sizeof(float64_t)*brows);
1306 
1307  cols=1;
1308  SGMatrix<float64_t> c=clustering->get_cluster_centers();
1309  rows=c.num_rows;
1310  cols=c.num_cols;
1311  centers=SG_MALLOC(float64_t, rows*cols);
1312  memcpy(centers, c.matrix, sizeof(float64_t)*rows*cols);
1313  break;
1314  }
1315 
1316  case CT_HIERARCHICAL:
1317  {
1318  CHierarchical* clustering=(CHierarchical*) classifier;
1319 
1320  // radi == merge_distances, centers == pairs
1321  bcols=1;
1322  SGVector<float64_t> r=clustering->get_merge_distances();
1323  brows=r.vlen;
1324  radi=SG_MALLOC(float64_t, brows);
1325  memcpy(radi, r.vector, sizeof(float64_t)*brows);
1326 
1327  SGMatrix<int32_t> p=clustering->get_cluster_pairs();
1328  rows=p.num_rows;
1329  cols=p.num_cols;
1330  centers=SG_MALLOC(float64_t, rows*cols);
1331  for (int32_t i=0; i<rows*cols; i++)
1332  centers[i]=(float64_t) p.matrix[i];
1333 
1334  break;
1335  }
1336 
1337  default:
1338  SG_ERROR("internal error - unknown clustering type\n")
1339  }
1340 
1341  return true;
1342 }
1343 
1345  float64_t* &weights, int32_t& rows, int32_t& cols, float64_t*& bias,
1346  int32_t& brows, int32_t& bcols)
1347 {
1349 
1350  if (!linear)
1351  return false;
1352 
1353  bias=SG_MALLOC(float64_t, 1);
1354  *bias=linear->get_bias();
1355  brows=1;
1356  bcols=1;
1357 
1358  SGVector<float64_t> w=linear->get_w();
1359  cols=1;
1360  rows=w.vlen;
1361 
1362  weights= SG_MALLOC(float64_t, w.vlen);
1363  memcpy(weights, w.vector, sizeof(float64_t)*w.vlen);
1364 
1365  return true;
1366 }
1367 
1369 {
1370  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1371  CFeatures* testfeatures=ui->ui_features->get_test_features();
1372 
1373  if (!classifier)
1374  {
1375  SG_ERROR("no kernelmachine available\n")
1376  return NULL;
1377  }
1378  if (!trainfeatures)
1379  {
1380  SG_ERROR("no training features available\n")
1381  return NULL;
1382  }
1383 
1384  if (!testfeatures)
1385  {
1386  SG_ERROR("no test features available\n")
1387  return NULL;
1388  }
1389 
1390  bool success=ui->ui_distance->init_distance("TEST");
1391 
1392  if (!success || !ui->ui_distance->is_initialized())
1393  {
1394  SG_ERROR("distance not initialized\n")
1395  return NULL;
1396  }
1397 
1398  ((CDistanceMachine*) classifier)->set_distance(
1399  ui->ui_distance->get_distance());
1400  SG_INFO("starting distance machine testing\n")
1401  return classifier->apply();
1402 }
1403 
1404 
1406 {
1407  CFeatures* testfeatures=ui->ui_features->get_test_features();
1408 
1409  if (!classifier)
1410  {
1411  SG_ERROR("no classifier available\n")
1412  return NULL;
1413  }
1414  if (!testfeatures)
1415  {
1416  SG_ERROR("no test features available\n")
1417  return NULL;
1418  }
1419  if (!(testfeatures->has_property(FP_DOT)))
1420  {
1421  SG_ERROR("testfeatures not based on DotFeatures\n")
1422  return NULL;
1423  }
1424 
1425  ((CLinearMachine*) classifier)->set_features((CDotFeatures*) testfeatures);
1426  SG_INFO("starting linear classifier testing\n")
1427  return classifier->apply();
1428 }
1429 
1431 {
1432  CFeatures* testfeatures=ui->ui_features->get_test_features();
1433 
1434  if (!classifier)
1435  {
1436  SG_ERROR("no svm available\n")
1437  return NULL;
1438  }
1439  if (!testfeatures)
1440  {
1441  SG_ERROR("no test features available\n")
1442  return NULL;
1443  }
1444  if (testfeatures->get_feature_class() != C_STRING ||
1445  testfeatures->get_feature_type() != F_BYTE )
1446  {
1447  SG_ERROR("testfeatures not of class STRING type BYTE\n")
1448  return NULL;
1449  }
1450 
1451  ((CWDSVMOcas*) classifier)->set_features((CStringFeatures<uint8_t>*) testfeatures);
1452  SG_INFO("starting linear classifier testing\n")
1453  return classifier->apply();
1454 }
1455 
1457 {
1458  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1459  CFeatures* testfeatures=ui->ui_features->get_test_features();
1460 
1461  if (!classifier)
1462  {
1463  SG_ERROR("no svm available\n")
1464  return false;
1465  }
1466 
1467  if (!ui->ui_kernel->is_initialized())
1468  {
1469  SG_ERROR("kernel not initialized\n")
1470  return false;
1471  }
1472 
1473  if (!ui->ui_kernel->get_kernel() ||
1474  ui->ui_kernel->get_kernel()->get_kernel_type()!=K_CUSTOM)
1475  {
1476  if (!trainfeatures)
1477  {
1478  SG_ERROR("no training features available\n")
1479  return false;
1480  }
1481 
1482  if (!testfeatures)
1483  {
1484  SG_ERROR("no test features available\n")
1485  return false;
1486  }
1487  }
1488 
1489  ((CKernelMachine*) classifier)->set_kernel(
1490  ui->ui_kernel->get_kernel());
1491 
1492  result=((CKernelMachine*)classifier)->apply_one(idx);
1493  return true ;
1494 }
1495 
1496 
1498 {
1499 #ifdef HAVE_LAPACK
1500  krr_tau=tau;
1501  ((CKernelRidgeRegression*) classifier)->set_tau(krr_tau);
1502  SG_INFO("Set to krr_tau=%f.\n", krr_tau)
1503 
1504  return true;
1505 #else
1506  return false;
1507 #endif
1508 }
1509 
1510 bool CGUIClassifier::set_solver(char* solver)
1511 {
1512  ESolverType s=ST_AUTO;
1513 
1514  if (strncmp(solver,"NEWTON", 6)==0)
1515  {
1516  SG_INFO("Using NEWTON solver.\n")
1517  s=ST_NEWTON;
1518  }
1519  else if (strncmp(solver,"DIRECT", 6)==0)
1520  {
1521  SG_INFO("Using DIRECT solver\n")
1522  s=ST_DIRECT;
1523  }
1524  else if (strncmp(solver,"BLOCK_NORM", 9)==0)
1525  {
1526  SG_INFO("Using BLOCK_NORM solver\n")
1527  s=ST_BLOCK_NORM;
1528  }
1529  else if (strncmp(solver,"ELASTICNET", 10)==0)
1530  {
1531  SG_INFO("Using ELASTICNET solver\n")
1532  s=ST_ELASTICNET;
1533  }
1534  else if (strncmp(solver,"AUTO", 4)==0)
1535  {
1536  SG_INFO("Automagically determining solver.\n")
1537  s=ST_AUTO;
1538  }
1539 #ifdef USE_CPLEX
1540  else if (strncmp(solver, "CPLEX", 5)==0)
1541  {
1542  SG_INFO("USING CPLEX METHOD selected\n")
1543  s=ST_CPLEX;
1544  }
1545 #endif
1546 #ifdef USE_GLPK
1547  else if (strncmp(solver,"GLPK", 4)==0)
1548  {
1549  SG_INFO("Using GLPK solver\n")
1550  s=ST_GLPK;
1551  }
1552 #endif
1553  else
1554  SG_ERROR("Unknown solver type, %s (not compiled in?)\n", solver)
1555 
1556 
1557  solver_type=s;
1558  return true;
1559 }
1560 
1562 {
1563  if (strcmp(name,"LIBSVM_ONECLASS")==0)
1564  {
1567  SG_INFO("created SVMlibsvm object for oneclass\n")
1568  }
1569  else if (strcmp(name,"LIBSVM_NU")==0)
1570  {
1572  constraint_generator= new CLibSVM(LIBSVM_NU_SVC);
1573  SG_INFO("created SVMlibsvm object\n")
1574  }
1575  else if (strcmp(name,"LIBSVM")==0)
1576  {
1579  SG_INFO("created SVMlibsvm object\n")
1580  }
1581 #ifdef USE_SVMLIGHT
1582  else if ((strcmp(name,"LIGHT")==0) || (strcmp(name,"SVMLIGHT")==0))
1583  {
1586  SG_INFO("created SVMLight object\n")
1587  }
1588  else if (strcmp(name,"SVMLIGHT_ONECLASS")==0)
1589  {
1592  SG_INFO("created SVMLightOneClass object\n")
1593  }
1594  else if (strcmp(name,"SVRLIGHT")==0)
1595  {
1598  SG_INFO("created SVRLight object\n")
1599  }
1600 #endif //USE_SVMLIGHT
1601  else if (strcmp(name,"GPBTSVM")==0)
1602  {
1605  SG_INFO("created GPBT-SVM object\n")
1606  }
1607  else if (strcmp(name,"MPDSVM")==0)
1608  {
1611  SG_INFO("created MPD-SVM object\n")
1612  }
1613  else if (strcmp(name,"GNPPSVM")==0)
1614  {
1617  SG_INFO("created GNPP-SVM object\n")
1618  }
1619  else if (strcmp(name,"LIBSVR")==0)
1620  {
1623  SG_INFO("created SVRlibsvm object\n")
1624  }
1625  else
1626  {
1627  SG_ERROR("Unknown SV-classifier %s.\n", name)
1628  return false;
1629  }
1631 
1632  return (constraint_generator!=NULL);
1633 }

SHOGUN Machine Learning Toolbox - Documentation