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  CSerializableAsciiFile* ascii_file = new CSerializableAsciiFile(model_file,'r');
811 
812  if (ascii_file)
813  {
814  if (classifier && classifier->load_serializable(ascii_file))
815  {
816  SG_DEBUG("file successfully read.\n")
817  result=true;
818  }
819  else
820  SG_ERROR("SVM/Classifier creation/loading failed on file %s.\n", filename)
821 
822  delete ascii_file;
823  }
824  else
825  SG_ERROR("Opening file %s failed.\n", filename)
826 
827  return result;
828  }
829  else
830  SG_ERROR("Type %s of SVM/Classifier unknown.\n", type)
831 
832  return false;
833 }
834 
835 bool CGUIClassifier::save(char* param)
836 {
837  bool result=false;
838  param=SGIO::skip_spaces(param);
839 
840  if (classifier)
841  {
842  FILE* file=fopen(param, "w");
843  CSerializableAsciiFile* ascii_file = new CSerializableAsciiFile(file,'w');
844 
845  if ((!ascii_file) || (!classifier->save_serializable(ascii_file)))
846  printf("writing to file %s failed!\n", param);
847  else
848  {
849  printf("successfully written classifier into \"%s\" !\n", param);
850  result=true;
851  }
852 
853  if (ascii_file)
854  delete ascii_file;
855  }
856  else
857  SG_ERROR("create classifier first\n")
858 
859  return result;
860 }
861 
863  float64_t learnrate, int32_t maxiter)
864 {
865  if (learnrate<=0)
867  else
868  perceptron_learnrate=learnrate;
869 
870  if (maxiter<=0)
871  perceptron_maxiter=1000;
872  else
873  perceptron_maxiter=maxiter;
874  SG_INFO("Setting to perceptron parameters (learnrate %f and maxiter: %d\n", perceptron_learnrate, perceptron_maxiter)
875 
876  return true;
877 }
878 
880 {
881  if (epsilon<0)
882  svm_epsilon=1e-4;
883  else
885  SG_INFO("Set to svm_epsilon=%f.\n", svm_epsilon)
886 
887  return true;
888 }
889 
891 {
892  if (max>0)
893  {
895  SG_INFO("Set to max_train_time=%f.\n", max_train_time)
896  }
897  else
898  SG_INFO("Disabling max_train_time.\n")
899 
900  return true;
901 }
902 
904 {
905  if (!classifier)
906  SG_ERROR("No regression method allocated\n")
907 
911  {
912  SG_ERROR("Underlying method not capable of SV-regression\n")
913  }
914 
915  if (tube_epsilon<0)
916  svm_tube_epsilon=1e-2;
917  svm_tube_epsilon=tube_epsilon;
918 
919  ((CSVM*) classifier)->set_tube_epsilon(svm_tube_epsilon);
920  SG_INFO("Set to svr_tube_epsilon=%f.\n", svm_tube_epsilon)
921 
922  return true;
923 }
924 
926 {
927  if (nu<0 || nu>1)
928  nu=0.5;
929 
930  svm_nu=nu;
931  SG_INFO("Set to nu=%f.\n", svm_nu)
932 
933  return true;
934 }
935 
937  float64_t weight_epsilon, float64_t C, float64_t norm)
938 {
939  if (weight_epsilon<0)
940  weight_epsilon=1e-4;
941  if (C<0)
942  C=0;
943  if (norm<0)
944  SG_ERROR("MKL norm >= 0\n")
945 
946  svm_weight_epsilon=weight_epsilon;
947  C_mkl=C;
948  mkl_norm=norm;
949 
950  SG_INFO("Set to weight_epsilon=%f.\n", svm_weight_epsilon)
951  SG_INFO("Set to C_mkl=%f.\n", C_mkl)
952  SG_INFO("Set to mkl_norm=%f.\n", mkl_norm)
953 
954  return true;
955 }
956 
958 {
959  if (lambda<0 || lambda>1)
960  SG_ERROR("0 <= ent_lambda <= 1\n")
961 
962  ent_lambda = lambda;
963  return true;
964 }
965 
967 {
968  if (mkl_bnorm<1)
969  SG_ERROR("1 <= mkl_block_norm <= inf\n")
970 
971  mkl_block_norm=mkl_bnorm;
972  return true;
973 }
974 
975 
977 {
978  if (C1<0)
979  svm_C1=1.0;
980  else
981  svm_C1=C1;
982 
983  if (C2<0)
984  svm_C2=svm_C1;
985  else
986  svm_C2=C2;
987 
988  SG_INFO("Set to C1=%f C2=%f.\n", svm_C1, svm_C2)
989 
990  return true;
991 }
992 
993 bool CGUIClassifier::set_svm_qpsize(int32_t qpsize)
994 {
995  if (qpsize<2)
996  svm_qpsize=41;
997  else
998  svm_qpsize=qpsize;
999  SG_INFO("Set qpsize to svm_qpsize=%d.\n", svm_qpsize)
1000 
1001  return true;
1002 }
1003 
1004 bool CGUIClassifier::set_svm_max_qpsize(int32_t max_qpsize)
1005 {
1006  if (max_qpsize<50)
1007  svm_max_qpsize=50;
1008  else
1009  svm_max_qpsize=max_qpsize;
1010  SG_INFO("Set max qpsize to svm_max_qpsize=%d.\n", svm_max_qpsize)
1011 
1012  return true;
1013 }
1014 
1015 bool CGUIClassifier::set_svm_bufsize(int32_t bufsize)
1016 {
1017  if (svm_bufsize<0)
1018  svm_bufsize=3000;
1019  else
1020  svm_bufsize=bufsize;
1021  SG_INFO("Set bufsize to svm_bufsize=%d.\n", svm_bufsize)
1022 
1023  return true ;
1024 }
1025 
1027 {
1028  svm_use_shrinking=enabled;
1029  if (svm_use_shrinking)
1030  SG_INFO("Enabling shrinking optimization.\n")
1031  else
1032  SG_INFO("Disabling shrinking optimization.\n")
1033 
1034  return true;
1035 }
1036 
1038 {
1039  svm_use_batch_computation=enabled;
1041  SG_INFO("Enabling batch computation.\n")
1042  else
1043  SG_INFO("Disabling batch computation.\n")
1044 
1045  return true;
1046 }
1047 
1049 {
1050  svm_use_linadd=enabled;
1051  if (svm_use_linadd)
1052  SG_INFO("Enabling LINADD optimization.\n")
1053  else
1054  SG_INFO("Disabling LINADD optimization.\n")
1055 
1056  return true;
1057 }
1058 
1060 {
1061  svm_use_bias=enabled;
1062  if (svm_use_bias)
1063  SG_INFO("Enabling svm bias.\n")
1064  else
1065  SG_INFO("Disabling svm bias.\n")
1066 
1067  return true;
1068 }
1069 
1071 {
1072  mkl_use_interleaved=enabled;
1073  if (mkl_use_interleaved)
1074  SG_INFO("Enabling mkl interleaved optimization.\n")
1075  else
1076  SG_INFO("Disabling mkl interleaved optimization.\n")
1077 
1078  return true;
1079 }
1080 
1082 {
1083  svm_do_auc_maximization=do_auc;
1084 
1086  SG_INFO("Enabling AUC maximization.\n")
1087  else
1088  SG_INFO("Disabling AUC maximization.\n")
1089 
1090  return true;
1091 }
1092 
1093 
1095 {
1097 
1098  switch (classifier->get_classifier_type())
1099  {
1100  case CT_LIGHT:
1101  case CT_LIGHTONECLASS:
1102  case CT_LIBSVM:
1103  case CT_SCATTERSVM:
1104  case CT_MPD:
1105  case CT_GPBT:
1106  case CT_CPLEXSVM:
1107  case CT_GMNPSVM:
1108  case CT_GNPPSVM:
1109  case CT_LIBSVR:
1110  case CT_LIBSVMMULTICLASS:
1111  case CT_LIBSVMONECLASS:
1112  case CT_SVRLIGHT:
1113  case CT_MKLCLASSIFICATION:
1114  case CT_MKLMULTICLASS:
1115  case CT_MKLREGRESSION:
1116  case CT_MKLONECLASS:
1118  return classify_kernelmachine();
1119  case CT_KNN:
1120  return classify_distancemachine();
1121  case CT_PERCEPTRON:
1122  case CT_LDA:
1123  return classify_linear();
1124  case CT_SVMLIN:
1125  case CT_SVMPERF:
1126  case CT_SVMOCAS:
1127  case CT_SVMSGD:
1128  case CT_LPM:
1129  case CT_LPBOOST:
1130  case CT_LIBLINEAR:
1131  return classify_linear();
1132  case CT_WDSVMOCAS:
1133  return classify_byte_linear();
1134  default:
1135  SG_ERROR("unknown classifier type\n")
1136  break;
1137  };
1138 
1139  return NULL;
1140 }
1141 
1143 {
1144  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1145  CFeatures* testfeatures=ui->ui_features->get_test_features();
1146 
1147  if (!classifier)
1148  SG_ERROR("No kernelmachine available.\n")
1149 
1150  bool success=true;
1151 
1152  REQUIRE(ui->ui_kernel->get_kernel(), "No kernel set");
1153  if (ui->ui_kernel->get_kernel()->get_kernel_type()!=K_CUSTOM)
1154  {
1155  if (ui->ui_kernel->get_kernel()->get_kernel_type()==K_COMBINED
1156  && ( !trainfeatures || !testfeatures ))
1157  {
1158  SG_DEBUG("skipping initialisation of combined kernel "
1159  "as train/test features are unavailable\n")
1160  }
1161  else
1162  {
1163  if (!trainfeatures)
1164  SG_ERROR("No training features available.\n")
1165  if (!testfeatures)
1166  SG_ERROR("No test features available.\n")
1167 
1168  success=ui->ui_kernel->init_kernel("TEST");
1169  }
1170  }
1171 
1172  if (!success || !ui->ui_kernel->is_initialized())
1173  SG_ERROR("Kernel not initialized.\n")
1174 
1176  if (type==CT_LARANK || type==CT_GMNPSVM || type==CT_LIBSVMMULTICLASS ||
1177  type==CT_MKLMULTICLASS)
1178  {
1180  kmcm->set_kernel(ui->ui_kernel->get_kernel());
1181  }
1182  else
1183  {
1185  km->set_kernel(ui->ui_kernel->get_kernel());
1187  }
1188 
1189  SG_INFO("Starting kernel machine testing.\n")
1190  return classifier->apply();
1191 }
1192 
1194  float64_t* &weights, int32_t &rows, int32_t &cols, float64_t*& bias,
1195  int32_t& brows, int32_t& bcols,
1196  int32_t idx) // which SVM for Multiclass
1197 {
1199 
1200  switch (classifier->get_classifier_type())
1201  {
1202  case CT_SCATTERSVM:
1203  case CT_GNPPSVM:
1204  case CT_LIBSVMMULTICLASS:
1205  case CT_LIGHT:
1206  case CT_LIGHTONECLASS:
1207  case CT_LIBSVM:
1208  case CT_MPD:
1209  case CT_GPBT:
1210  case CT_CPLEXSVM:
1211  case CT_GMNPSVM:
1212  case CT_LIBSVR:
1213  case CT_LIBSVMONECLASS:
1214  case CT_SVRLIGHT:
1215  case CT_MKLCLASSIFICATION:
1216  case CT_MKLREGRESSION:
1217  case CT_MKLONECLASS:
1218  case CT_MKLMULTICLASS:
1220  return get_svm(weights, rows, cols, bias, brows, bcols, idx);
1221  break;
1222  case CT_PERCEPTRON:
1223  case CT_LDA:
1224  case CT_LPM:
1225  case CT_LPBOOST:
1226  case CT_SVMOCAS:
1227  case CT_SVMSGD:
1228  case CT_SVMLIN:
1229  case CT_SVMPERF:
1230  case CT_LIBLINEAR:
1231  return get_linear(weights, rows, cols, bias, brows, bcols);
1232  break;
1233  case CT_KMEANS:
1234  case CT_HIERARCHICAL:
1235  return get_clustering(weights, rows, cols, bias, brows, bcols);
1236  break;
1237  case CT_KNN:
1238  SG_ERROR("not implemented")
1239  break;
1240  default:
1241  SG_ERROR("unknown classifier type\n")
1242  break;
1243  };
1244  return false;
1245 }
1246 
1247 
1249 {
1251  return ((CMulticlassSVM*) classifier)->get_num_machines();
1252 }
1253 
1255  float64_t* &weights, int32_t& rows, int32_t& cols, float64_t*& bias,
1256  int32_t& brows, int32_t& bcols, int32_t idx)
1257 {
1258  CSVM* svm=(CSVM*) classifier;
1259 
1260  if (idx>-1) // should be MulticlassSVM
1261  svm=((CMulticlassSVM*) svm)->get_svm(idx);
1262 
1263  if (svm)
1264  {
1265  brows=1;
1266  bcols=1;
1267  bias=SG_MALLOC(float64_t, 1);
1268  *bias=svm->get_bias();
1269 
1270  rows=svm->get_num_support_vectors();
1271  cols=2;
1272  weights=SG_MALLOC(float64_t, rows*cols);
1273 
1274  for (int32_t i=0; i<rows; i++)
1275  {
1276  weights[i]=svm->get_alpha(i);
1277  weights[i+rows]=svm->get_support_vector(i);
1278  }
1279 
1280  return true;
1281  }
1282 
1283  return false;
1284 }
1285 
1287  float64_t* &centers, int32_t& rows, int32_t& cols, float64_t*& radi,
1288  int32_t& brows, int32_t& bcols)
1289 {
1290  if (!classifier)
1291  return false;
1292 
1293  switch (classifier->get_classifier_type())
1294  {
1295  case CT_KMEANS:
1296  {
1297  CKMeans* clustering=(CKMeans*) classifier;
1298 
1299  bcols=1;
1300  SGVector<float64_t> r=clustering->get_radiuses();
1301  brows=r.vlen;
1302  radi=SG_MALLOC(float64_t, brows);
1303  memcpy(radi, r.vector, sizeof(float64_t)*brows);
1304 
1305  cols=1;
1306  SGMatrix<float64_t> c=clustering->get_cluster_centers();
1307  rows=c.num_rows;
1308  cols=c.num_cols;
1309  centers=SG_MALLOC(float64_t, rows*cols);
1310  memcpy(centers, c.matrix, sizeof(float64_t)*rows*cols);
1311  break;
1312  }
1313 
1314  case CT_HIERARCHICAL:
1315  {
1316  CHierarchical* clustering=(CHierarchical*) classifier;
1317 
1318  // radi == merge_distances, centers == pairs
1319  bcols=1;
1320  SGVector<float64_t> r=clustering->get_merge_distances();
1321  brows=r.vlen;
1322  radi=SG_MALLOC(float64_t, brows);
1323  memcpy(radi, r.vector, sizeof(float64_t)*brows);
1324 
1325  SGMatrix<int32_t> p=clustering->get_cluster_pairs();
1326  rows=p.num_rows;
1327  cols=p.num_cols;
1328  centers=SG_MALLOC(float64_t, rows*cols);
1329  for (int32_t i=0; i<rows*cols; i++)
1330  centers[i]=(float64_t) p.matrix[i];
1331 
1332  break;
1333  }
1334 
1335  default:
1336  SG_ERROR("internal error - unknown clustering type\n")
1337  }
1338 
1339  return true;
1340 }
1341 
1343  float64_t* &weights, int32_t& rows, int32_t& cols, float64_t*& bias,
1344  int32_t& brows, int32_t& bcols)
1345 {
1347 
1348  if (!linear)
1349  return false;
1350 
1351  bias=SG_MALLOC(float64_t, 1);
1352  *bias=linear->get_bias();
1353  brows=1;
1354  bcols=1;
1355 
1356  SGVector<float64_t> w=linear->get_w();
1357  cols=1;
1358  rows=w.vlen;
1359 
1360  weights= SG_MALLOC(float64_t, w.vlen);
1361  memcpy(weights, w.vector, sizeof(float64_t)*w.vlen);
1362 
1363  return true;
1364 }
1365 
1367 {
1368  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1369  CFeatures* testfeatures=ui->ui_features->get_test_features();
1370 
1371  if (!classifier)
1372  {
1373  SG_ERROR("no kernelmachine available\n")
1374  return NULL;
1375  }
1376  if (!trainfeatures)
1377  {
1378  SG_ERROR("no training features available\n")
1379  return NULL;
1380  }
1381 
1382  if (!testfeatures)
1383  {
1384  SG_ERROR("no test features available\n")
1385  return NULL;
1386  }
1387 
1388  bool success=ui->ui_distance->init_distance("TEST");
1389 
1390  if (!success || !ui->ui_distance->is_initialized())
1391  {
1392  SG_ERROR("distance not initialized\n")
1393  return NULL;
1394  }
1395 
1396  ((CDistanceMachine*) classifier)->set_distance(
1397  ui->ui_distance->get_distance());
1398  SG_INFO("starting distance machine testing\n")
1399  return classifier->apply();
1400 }
1401 
1402 
1404 {
1405  CFeatures* testfeatures=ui->ui_features->get_test_features();
1406 
1407  if (!classifier)
1408  {
1409  SG_ERROR("no classifier available\n")
1410  return NULL;
1411  }
1412  if (!testfeatures)
1413  {
1414  SG_ERROR("no test features available\n")
1415  return NULL;
1416  }
1417  if (!(testfeatures->has_property(FP_DOT)))
1418  {
1419  SG_ERROR("testfeatures not based on DotFeatures\n")
1420  return NULL;
1421  }
1422 
1423  ((CLinearMachine*) classifier)->set_features((CDotFeatures*) testfeatures);
1424  SG_INFO("starting linear classifier testing\n")
1425  return classifier->apply();
1426 }
1427 
1429 {
1430  CFeatures* testfeatures=ui->ui_features->get_test_features();
1431 
1432  if (!classifier)
1433  {
1434  SG_ERROR("no svm available\n")
1435  return NULL;
1436  }
1437  if (!testfeatures)
1438  {
1439  SG_ERROR("no test features available\n")
1440  return NULL;
1441  }
1442  if (testfeatures->get_feature_class() != C_STRING ||
1443  testfeatures->get_feature_type() != F_BYTE )
1444  {
1445  SG_ERROR("testfeatures not of class STRING type BYTE\n")
1446  return NULL;
1447  }
1448 
1449  ((CWDSVMOcas*) classifier)->set_features((CStringFeatures<uint8_t>*) testfeatures);
1450  SG_INFO("starting linear classifier testing\n")
1451  return classifier->apply();
1452 }
1453 
1455 {
1456  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1457  CFeatures* testfeatures=ui->ui_features->get_test_features();
1458 
1459  if (!classifier)
1460  {
1461  SG_ERROR("no svm available\n")
1462  return false;
1463  }
1464 
1465  if (!ui->ui_kernel->is_initialized())
1466  {
1467  SG_ERROR("kernel not initialized\n")
1468  return false;
1469  }
1470 
1471  if (!ui->ui_kernel->get_kernel() ||
1472  ui->ui_kernel->get_kernel()->get_kernel_type()!=K_CUSTOM)
1473  {
1474  if (!trainfeatures)
1475  {
1476  SG_ERROR("no training features available\n")
1477  return false;
1478  }
1479 
1480  if (!testfeatures)
1481  {
1482  SG_ERROR("no test features available\n")
1483  return false;
1484  }
1485  }
1486 
1487  ((CKernelMachine*) classifier)->set_kernel(
1488  ui->ui_kernel->get_kernel());
1489 
1490  result=((CKernelMachine*)classifier)->apply_one(idx);
1491  return true ;
1492 }
1493 
1494 
1496 {
1497 #ifdef HAVE_LAPACK
1498  krr_tau=tau;
1499  ((CKernelRidgeRegression*) classifier)->set_tau(krr_tau);
1500  SG_INFO("Set to krr_tau=%f.\n", krr_tau)
1501 
1502  return true;
1503 #else
1504  return false;
1505 #endif
1506 }
1507 
1508 bool CGUIClassifier::set_solver(char* solver)
1509 {
1510  ESolverType s=ST_AUTO;
1511 
1512  if (strncmp(solver,"NEWTON", 6)==0)
1513  {
1514  SG_INFO("Using NEWTON solver.\n")
1515  s=ST_NEWTON;
1516  }
1517  else if (strncmp(solver,"DIRECT", 6)==0)
1518  {
1519  SG_INFO("Using DIRECT solver\n")
1520  s=ST_DIRECT;
1521  }
1522  else if (strncmp(solver,"BLOCK_NORM", 9)==0)
1523  {
1524  SG_INFO("Using BLOCK_NORM solver\n")
1525  s=ST_BLOCK_NORM;
1526  }
1527  else if (strncmp(solver,"ELASTICNET", 10)==0)
1528  {
1529  SG_INFO("Using ELASTICNET solver\n")
1530  s=ST_ELASTICNET;
1531  }
1532  else if (strncmp(solver,"AUTO", 4)==0)
1533  {
1534  SG_INFO("Automagically determining solver.\n")
1535  s=ST_AUTO;
1536  }
1537 #ifdef USE_CPLEX
1538  else if (strncmp(solver, "CPLEX", 5)==0)
1539  {
1540  SG_INFO("USING CPLEX METHOD selected\n")
1541  s=ST_CPLEX;
1542  }
1543 #endif
1544 #ifdef USE_GLPK
1545  else if (strncmp(solver,"GLPK", 4)==0)
1546  {
1547  SG_INFO("Using GLPK solver\n")
1548  s=ST_GLPK;
1549  }
1550 #endif
1551  else
1552  SG_ERROR("Unknown solver type, %s (not compiled in?)\n", solver)
1553 
1554 
1555  solver_type=s;
1556  return true;
1557 }
1558 
1560 {
1561  if (strcmp(name,"LIBSVM_ONECLASS")==0)
1562  {
1565  SG_INFO("created SVMlibsvm object for oneclass\n")
1566  }
1567  else if (strcmp(name,"LIBSVM_NU")==0)
1568  {
1570  constraint_generator= new CLibSVM(LIBSVM_NU_SVC);
1571  SG_INFO("created SVMlibsvm object\n")
1572  }
1573  else if (strcmp(name,"LIBSVM")==0)
1574  {
1577  SG_INFO("created SVMlibsvm object\n")
1578  }
1579 #ifdef USE_SVMLIGHT
1580  else if ((strcmp(name,"LIGHT")==0) || (strcmp(name,"SVMLIGHT")==0))
1581  {
1584  SG_INFO("created SVMLight object\n")
1585  }
1586  else if (strcmp(name,"SVMLIGHT_ONECLASS")==0)
1587  {
1590  SG_INFO("created SVMLightOneClass object\n")
1591  }
1592  else if (strcmp(name,"SVRLIGHT")==0)
1593  {
1596  SG_INFO("created SVRLight object\n")
1597  }
1598 #endif //USE_SVMLIGHT
1599  else if (strcmp(name,"GPBTSVM")==0)
1600  {
1603  SG_INFO("created GPBT-SVM object\n")
1604  }
1605  else if (strcmp(name,"MPDSVM")==0)
1606  {
1609  SG_INFO("created MPD-SVM object\n")
1610  }
1611  else if (strcmp(name,"GNPPSVM")==0)
1612  {
1615  SG_INFO("created GNPP-SVM object\n")
1616  }
1617  else if (strcmp(name,"LIBSVR")==0)
1618  {
1621  SG_INFO("created SVRlibsvm object\n")
1622  }
1623  else
1624  {
1625  SG_ERROR("Unknown SV-classifier %s.\n", name)
1626  return false;
1627  }
1629 
1630  return (constraint_generator!=NULL);
1631 }

SHOGUN Machine Learning Toolbox - Documentation