SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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/features/Labels.h>
20 
22 
23 #include <shogun/classifier/KNN.h>
27 
28 #include <shogun/classifier/LDA.h>
29 #include <shogun/classifier/LPM.h>
32 
34 
35 
36 
46 
48 #include <shogun/regression/KRR.h>
49 
55 
62 
63 using namespace shogun;
64 
66 : CSGObject(), ui(ui_)
67 {
69  classifier=NULL;
71 
72  // Perceptron parameters
74  perceptron_maxiter=1000;
75 
76  // SVM parameters
77  svm_qpsize=41;
78  svm_bufsize=3000;
79  svm_max_qpsize=1000;
80  mkl_norm=1;
81  ent_lambda=0;
83  svm_C1=1;
84  svm_C2=1;
85  C_mkl=0;
87  svm_weight_epsilon=1e-5;
88  svm_epsilon=1e-5;
89  svm_tube_epsilon=1e-2;
90  svm_nu=0.5;
91  svm_use_shrinking = true ;
92 
93  svm_use_bias = true;
95  svm_use_linadd = true ;
96  svm_do_auc_maximization = false ;
97 
98  // KRR parameters
99  krr_tau=1;
100 
102 }
103 
105 {
108 }
109 
110 bool CGUIClassifier::new_classifier(char* name, int32_t d, int32_t from_d)
111 {
112  if (strcmp(name,"LIBSVM_ONECLASS")==0)
113  {
115  classifier = new CLibSVMOneClass();
116  SG_INFO("created SVMlibsvm object for oneclass\n");
117  }
118  else if (strcmp(name,"LIBSVM_MULTICLASS")==0)
119  {
122  SG_INFO("created SVMlibsvm object for multiclass\n");
123  }
124  else if (strcmp(name,"LIBSVM_NUMULTICLASS")==0)
125  {
127  classifier= new CLibSVMMultiClass(LIBSVM_NU_SVC);
128  SG_INFO("created SVMlibsvm object for multiclass\n") ;
129  }
130 
131  else if (strcmp(name,"SCATTERSVM_NO_BIAS_LIBSVM")==0)
132  {
135  SG_INFO("created ScatterSVM NO BIAS LIBSVM object\n") ;
136  }
137  else if (strcmp(name,"SCATTERSVM_TESTRULE1")==0)
138  {
141  SG_INFO("created ScatterSVM TESTRULE1 object\n") ;
142  }
143  else if (strcmp(name,"SCATTERSVM_TESTRULE2")==0)
144  {
147  SG_INFO("created ScatterSVM TESTRULE2 object\n") ;
148  }
149  else if (strcmp(name,"LIBSVM_NU")==0)
150  {
152  classifier= new CLibSVM(LIBSVM_NU_SVC);
153  SG_INFO("created SVMlibsvm object\n") ;
154  }
155  else if (strcmp(name,"LIBSVM")==0)
156  {
158  classifier= new CLibSVM();
159  SG_INFO("created SVMlibsvm object\n") ;
160  }
161  else if (strcmp(name,"LARANK")==0)
162  {
164  classifier= new CLaRank();
165  SG_INFO("created LaRank object\n") ;
166  }
167 
168  else if (strcmp(name,"GPBTSVM")==0)
169  {
171  classifier= new CGPBTSVM();
172  SG_INFO("created GPBT-SVM object\n") ;
173  }
174  else if (strcmp(name,"MPDSVM")==0)
175  {
177  classifier= new CMPDSVM();
178  SG_INFO("created MPD-SVM object\n") ;
179  }
180  else if (strcmp(name,"GNPPSVM")==0)
181  {
183  classifier= new CGNPPSVM();
184  SG_INFO("created GNPP-SVM object\n") ;
185  }
186  else if (strcmp(name,"GMNPSVM")==0)
187  {
189  classifier= new CGMNPSVM();
190  SG_INFO("created GMNP-SVM object\n") ;
191  }
192  else if (strcmp(name,"LIBSVR")==0)
193  {
195  classifier= new CLibSVR();
196  SG_INFO("created SVRlibsvm object\n") ;
197  }
198 #ifdef HAVE_LAPACK
199  else if (strcmp(name, "KRR")==0)
200  {
202  classifier=new CKRR(krr_tau, ui->ui_kernel->get_kernel(),
203  ui->ui_labels->get_train_labels());
204  SG_INFO("created KRR object %p\n", classifier);
205  }
206 #endif //HAVE_LAPACK
207  else if (strcmp(name,"PERCEPTRON")==0)
208  {
210  classifier= new CPerceptron();
211  SG_INFO("created Perceptron object\n") ;
212  }
213 #ifdef HAVE_LAPACK
214  else if (strncmp(name,"LIBLINEAR",9)==0)
215  {
217 
218  if (strcmp(name,"LIBLINEAR_L2R_LR")==0)
219  {
220  st=L2R_LR;
221  SG_INFO("created LibLinear l2 regularized logistic regression object\n") ;
222  }
223  else if (strcmp(name,"LIBLINEAR_L2R_L2LOSS_SVC_DUAL")==0)
224  {
226  SG_INFO("created LibLinear l2 regularized l2 loss SVM dual object\n") ;
227  }
228  else if (strcmp(name,"LIBLINEAR_L2R_L2LOSS_SVC")==0)
229  {
230  st=L2R_L2LOSS_SVC;
231  SG_INFO("created LibLinear l2 regularized l2 loss SVM primal object\n") ;
232  }
233  else if (strcmp(name,"LIBLINEAR_L1R_L2LOSS_SVC")==0)
234  {
235  st=L1R_L2LOSS_SVC;
236  SG_INFO("created LibLinear l1 regularized l2 loss SVM primal object\n") ;
237  }
238  else if (strcmp(name,"LIBLINEAR_L2R_L1LOSS_SVC_DUAL")==0)
239  {
241  SG_INFO("created LibLinear l2 regularized l1 loss dual SVM object\n") ;
242  }
243  else
244  SG_ERROR("unknown liblinear type\n");
245 
247  classifier= new CLibLinear(st);
248  ((CLibLinear*) classifier)->set_C(svm_C1, svm_C2);
249  ((CLibLinear*) classifier)->set_epsilon(svm_epsilon);
250  ((CLibLinear*) classifier)->set_bias_enabled(svm_use_bias);
251  }
252  else if (strcmp(name,"LDA")==0)
253  {
255  classifier= new CLDA();
256  SG_INFO("created LDA object\n") ;
257  }
258 #endif //HAVE_LAPACK
259 #ifdef USE_CPLEX
260  else if (strcmp(name,"LPM")==0)
261  {
263  classifier= new CLPM();
264  ((CLPM*) classifier)->set_C(svm_C1, svm_C2);
265  ((CLPM*) classifier)->set_epsilon(svm_epsilon);
266  ((CLPM*) classifier)->set_bias_enabled(svm_use_bias);
267  ((CLPM*) classifier)->set_max_train_time(max_train_time);
268  SG_INFO("created LPM object\n") ;
269  }
270  else if (strcmp(name,"LPBOOST")==0)
271  {
273  classifier= new CLPBoost();
274  ((CLPBoost*) classifier)->set_C(svm_C1, svm_C2);
275  ((CLPBoost*) classifier)->set_epsilon(svm_epsilon);
276  ((CLPBoost*) classifier)->set_bias_enabled(svm_use_bias);
277  ((CLPBoost*) classifier)->set_max_train_time(max_train_time);
278  SG_INFO("created LPBoost object\n") ;
279  }
280  else if (strcmp(name,"SUBGRADIENTLPM")==0)
281  {
284 
285  ((CSubGradientLPM*) classifier)->set_bias_enabled(svm_use_bias);
286  ((CSubGradientLPM*) classifier)->set_qpsize(svm_qpsize);
287  ((CSubGradientLPM*) classifier)->set_qpsize_max(svm_max_qpsize);
288  ((CSubGradientLPM*) classifier)->set_C(svm_C1, svm_C2);
289  ((CSubGradientLPM*) classifier)->set_epsilon(svm_epsilon);
290  ((CSubGradientLPM*) classifier)->set_max_train_time(max_train_time);
291  SG_INFO("created Subgradient LPM object\n") ;
292  }
293 #endif //USE_CPLEX
294  else if (strncmp(name,"KNN", strlen("KNN"))==0)
295  {
297  classifier= new CKNN();
298  SG_INFO("created KNN object\n") ;
299  }
300  else if (strncmp(name,"KMEANS", strlen("KMEANS"))==0)
301  {
303  classifier= new CKMeans();
304  SG_INFO("created KMeans object\n") ;
305  }
306  else if (strncmp(name,"HIERARCHICAL", strlen("HIERARCHICAL"))==0)
307  {
309  classifier= new CHierarchical();
310  SG_INFO("created Hierarchical clustering object\n") ;
311  }
312  else if (strcmp(name,"SVMLIN")==0)
313  {
315  classifier= new CSVMLin();
316  ((CSVMLin*) classifier)->set_C(svm_C1, svm_C2);
317  ((CSVMLin*) classifier)->set_epsilon(svm_epsilon);
318  ((CSVMLin*) classifier)->set_bias_enabled(svm_use_bias);
319  SG_INFO("created SVMLin object\n") ;
320  }
321  else if (strcmp(name,"SUBGRADIENTSVM")==0)
322  {
325 
326  ((CSubGradientSVM*) classifier)->set_bias_enabled(svm_use_bias);
327  ((CSubGradientSVM*) classifier)->set_qpsize(svm_qpsize);
328  ((CSubGradientSVM*) classifier)->set_qpsize_max(svm_max_qpsize);
329  ((CSubGradientSVM*) classifier)->set_C(svm_C1, svm_C2);
330  ((CSubGradientSVM*) classifier)->set_epsilon(svm_epsilon);
331  ((CSubGradientSVM*) classifier)->set_max_train_time(max_train_time);
332  SG_INFO("created Subgradient SVM object\n") ;
333  }
334  else if (strncmp(name,"WDSVMOCAS", strlen("WDSVMOCAS"))==0)
335  {
337  classifier= new CWDSVMOcas(SVM_OCAS);
338 
339  ((CWDSVMOcas*) classifier)->set_bias_enabled(svm_use_bias);
340  ((CWDSVMOcas*) classifier)->set_degree(d, from_d);
341  ((CWDSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
342  ((CWDSVMOcas*) classifier)->set_epsilon(svm_epsilon);
343  ((CWDSVMOcas*) classifier)->set_bufsize(svm_bufsize);
344  SG_INFO("created Weighted Degree Kernel SVM Ocas(OCAS) object of order %d (from order:%d)\n", d, from_d) ;
345  }
346  else if (strcmp(name,"SVMOCAS")==0)
347  {
349  classifier= new CSVMOcas(SVM_OCAS);
350 
351  ((CSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
352  ((CSVMOcas*) classifier)->set_epsilon(svm_epsilon);
353  ((CSVMOcas*) classifier)->set_bufsize(svm_bufsize);
354  ((CSVMOcas*) classifier)->set_bias_enabled(svm_use_bias);
355  SG_INFO("created SVM Ocas(OCAS) object\n") ;
356  }
357  else if (strcmp(name,"SVMSGD")==0)
358  {
360  classifier= new CSVMSGD(svm_C1);
361  ((CSVMSGD*) classifier)->set_bias_enabled(svm_use_bias);
362  SG_INFO("created SVM SGD object\n") ;
363  }
364  else if (strcmp(name,"SVMBMRM")==0 || (strcmp(name,"SVMPERF")==0))
365  {
367  classifier= new CSVMOcas(SVM_BMRM);
368 
369  ((CSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
370  ((CSVMOcas*) classifier)->set_epsilon(svm_epsilon);
371  ((CSVMOcas*) classifier)->set_bufsize(svm_bufsize);
372  ((CSVMOcas*) classifier)->set_bias_enabled(svm_use_bias);
373  SG_INFO("created SVM Ocas(BMRM/PERF) object\n") ;
374  }
375  else if (strcmp(name,"MKL_CLASSIFICATION")==0)
376  {
379  }
380  //else if (strcmp(name,"MKL_MULTICLASS")==0)
381  //{
382  // SG_UNREF(classifier);
383  // classifier= new CMKLClassification();
384  //}
385  else if (strcmp(name,"MKL_ONECLASS")==0)
386  {
388  classifier= new CMKLOneClass();
389  }
390  else if (strcmp(name,"MKL_MULTICLASS")==0)
391  {
393  classifier= new CMKLMultiClass();
394  }
395  else if (strcmp(name,"MKL_REGRESSION")==0)
396  {
398  classifier= new CMKLRegression();
399  }
400  else
401  {
402  SG_ERROR("Unknown classifier %s.\n", name);
403  return false;
404  }
406 
407  return (classifier!=NULL);
408 }
409 
411 {
413  if (!mkl)
414  SG_ERROR("No MKL available.\n");
415 
416  CLabels* trainlabels=ui->ui_labels->get_train_labels();
417  if (!trainlabels)
418  SG_ERROR("No trainlabels available.\n");
419 
420  CKernel* kernel=ui->ui_kernel->get_kernel();
421  if (!kernel)
422  SG_ERROR("No kernel available.\n");
423 
424  bool success=ui->ui_kernel->init_kernel("TRAIN");
425 
426  if (!success || !ui->ui_kernel->is_initialized() || !kernel->has_features())
427  SG_ERROR("Kernel not initialized / no train features available.\n");
428 
429  int32_t num_vec=kernel->get_num_vec_lhs();
430  if (trainlabels->get_num_labels() != num_vec)
431  SG_ERROR("Number of train labels (%d) and training vectors (%d) differs!\n", trainlabels->get_num_labels(), num_vec);
432 
433  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);
434 
436  mkl->set_mkl_norm(mkl_norm);
437  //mkl->set_max_num_mkliters(-1);
440  mkl->set_epsilon(svm_epsilon);
443  mkl->set_nu(svm_nu);
444  mkl->set_C(svm_C1, svm_C2);
445  mkl->set_qpsize(svm_qpsize);
449 
450  ((CKernelMachine*) mkl)->set_labels(trainlabels);
451  ((CKernelMachine*) mkl)->set_kernel(kernel);
452 
453  return mkl->train();
454 }
455 
457 {
458  CMKL* mkl= (CMKL*) classifier;
459  if (!mkl)
460  SG_ERROR("No SVM available.\n");
461 
462  bool oneclass=(mkl->get_classifier_type()==CT_LIBSVMONECLASS);
463  CLabels* trainlabels=NULL;
464  if(!oneclass)
465  trainlabels=ui->ui_labels->get_train_labels();
466  else
467  SG_INFO("Training one class mkl.\n");
468  if (!trainlabels && !oneclass)
469  SG_ERROR("No trainlabels available.\n");
470 
471  CKernel* kernel=ui->ui_kernel->get_kernel();
472  if (!kernel)
473  SG_ERROR("No kernel available.\n");
474 
475  bool success=ui->ui_kernel->init_kernel("TRAIN");
476  if (!success || !ui->ui_kernel->is_initialized() || !kernel->has_features())
477  SG_ERROR("Kernel not initialized.\n");
478 
479  int32_t num_vec=kernel->get_num_vec_lhs();
480  if (!oneclass && trainlabels->get_num_labels() != num_vec)
481  SG_ERROR("Number of train labels (%d) and training vectors (%d) differs!\n", trainlabels->get_num_labels(), num_vec);
482 
483  SG_INFO("Starting SVM training on %ld vectors using C1=%lf C2=%lf epsilon=%lf\n", num_vec, svm_C1, svm_C2, svm_epsilon);
484 
489  mkl->set_epsilon(svm_epsilon);
492  mkl->set_nu(svm_nu);
493  mkl->set_C(svm_C1, svm_C2);
494  mkl->set_qpsize(svm_qpsize);
499  mkl->set_mkl_norm(mkl_norm);
502  mkl->set_C_mkl(C_mkl);
504 
506  {
507  CAUCKernel* auc_kernel = new CAUCKernel(10, kernel);
508  CLabels* auc_labels= auc_kernel->setup_auc_maximization(trainlabels);
509  ((CKernelMachine*) mkl)->set_labels(auc_labels);
510  ((CKernelMachine*) mkl)->set_kernel(auc_kernel);
511  SG_UNREF(auc_labels);
512  }
513  else
514  {
515  if(!oneclass)
516  ((CKernelMachine*) mkl)->set_labels(trainlabels);
517  ((CKernelMachine*) mkl)->set_kernel(kernel);
518  }
519 
520  bool result=mkl->train();
521 
522  return result;
523 }
524 
526 {
527  CSVM* svm= (CSVM*) classifier;
528  if (!svm)
529  SG_ERROR("No SVM available.\n");
530 
531  bool oneclass=(svm->get_classifier_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 
557  svm->set_epsilon(svm_epsilon);
560  svm->set_nu(svm_nu);
561  svm->set_C(svm_C1, svm_C2);
562  svm->set_qpsize(svm_qpsize);
566 
568  {
569  ((CMKLMultiClass *)svm)->set_mkl_epsilon(svm_weight_epsilon );
570  }
571 
573  {
574  CAUCKernel* auc_kernel = new CAUCKernel(10, kernel);
575  CLabels* auc_labels= auc_kernel->setup_auc_maximization(trainlabels);
576  ((CKernelMachine*) svm)->set_labels(auc_labels);
577  ((CKernelMachine*) svm)->set_kernel(auc_kernel);
578  SG_UNREF(auc_labels);
579  }
580  else
581  {
582  if(!oneclass)
583  ((CKernelMachine*) svm)->set_labels(trainlabels);
584  ((CKernelMachine*) svm)->set_kernel(kernel);
585  }
586 
587  bool result=svm->train();
588 
589  return result;
590 }
591 
592 bool CGUIClassifier::train_clustering(int32_t k, int32_t max_iter)
593 {
594  bool result=false;
595  CDistance* distance=ui->ui_distance->get_distance();
596 
597  if (!distance)
598  SG_ERROR("No distance available\n");
599 
600  if (!ui->ui_distance->init_distance("TRAIN"))
601  SG_ERROR("Initializing distance with train features failed.\n");
602 
603  ((CDistanceMachine*) classifier)->set_distance(distance);
604 
606  switch (type)
607  {
608  case CT_KMEANS:
609  {
610  ((CKMeans*) classifier)->set_k(k);
611  ((CKMeans*) classifier)->set_max_iter(max_iter);
612  result=((CKMeans*) classifier)->train();
613  break;
614  }
615  case CT_HIERARCHICAL:
616  {
617  ((CHierarchical*) classifier)->set_merges(k);
618  result=((CHierarchical*) classifier)->train();
619  break;
620  }
621  default:
622  SG_ERROR("Unknown clustering type %d\n", type);
623  }
624 
625  return result;
626 }
627 
629 {
630  CLabels* trainlabels=ui->ui_labels->get_train_labels();
631  CDistance* distance=ui->ui_distance->get_distance();
632 
633  bool result=false;
634 
635  if (trainlabels)
636  {
637  if (distance)
638  {
639  if (!ui->ui_distance->init_distance("TRAIN"))
640  SG_ERROR("Initializing distance with train features failed.\n");
641  ((CKNN*) classifier)->set_labels(trainlabels);
642  ((CKNN*) classifier)->set_distance(distance);
643  ((CKNN*) classifier)->set_k(k);
644  result=((CKNN*) classifier)->train();
645  }
646  else
647  SG_ERROR("No distance available.\n");
648  }
649  else
650  SG_ERROR("No labels available\n");
651 
652  return result;
653 }
654 
656 {
657 #ifdef HAVE_LAPACK
658  CKRR* krr= (CKRR*) classifier;
659  if (!krr)
660  SG_ERROR("No SVM available.\n");
661 
662  CLabels* trainlabels=NULL;
663  trainlabels=ui->ui_labels->get_train_labels();
664  if (!trainlabels)
665  SG_ERROR("No trainlabels available.\n");
666 
667  CKernel* kernel=ui->ui_kernel->get_kernel();
668  if (!kernel)
669  SG_ERROR("No kernel available.\n");
670 
671  bool success=ui->ui_kernel->init_kernel("TRAIN");
672 
673  if (!success || !ui->ui_kernel->is_initialized() || !kernel->has_features())
674  SG_ERROR("Kernel not initialized / no train features available.\n");
675 
676  int32_t num_vec=kernel->get_num_vec_lhs();
677  if (trainlabels->get_num_labels() != num_vec)
678  SG_ERROR("Number of train labels (%d) and training vectors (%d) differs!\n", trainlabels->get_num_labels(), num_vec);
679 
680 
681  // Set training labels and kernel
682  krr->set_labels(trainlabels);
683  krr->set_kernel(kernel);
684 
685  bool result=krr->train();
686  return result;
687 #else
688  return false;
689 #endif
690 }
691 
693 {
696  CFeatures* trainfeatures=ui->ui_features->get_train_features();
697  CLabels* trainlabels=ui->ui_labels->get_train_labels();
698  bool result=false;
699 
700  if (!trainfeatures)
701  SG_ERROR("No trainfeatures available.\n");
702 
703  if (!trainfeatures->has_property(FP_DOT))
704  SG_ERROR("Trainfeatures not based on DotFeatures.\n");
705 
706  if (!trainlabels)
707  SG_ERROR("No labels available\n");
708 
709  if (ctype==CT_PERCEPTRON)
710  {
711  ((CPerceptron*) classifier)->set_learn_rate(perceptron_learnrate);
712  ((CPerceptron*) classifier)->set_max_iter(perceptron_maxiter);
713  }
714 
715 #ifdef HAVE_LAPACK
716  if (ctype==CT_LDA)
717  {
718  if (trainfeatures->get_feature_type()!=F_DREAL ||
719  trainfeatures->get_feature_class()!=C_SIMPLE)
720  SG_ERROR("LDA requires train features of class SIMPLE type REAL.\n");
721  ((CLDA*) classifier)->set_gamma(gamma);
722  }
723 #endif
724 
725  if (ctype==CT_SVMOCAS)
726  ((CSVMOcas*) classifier)->set_C(svm_C1, svm_C2);
727 #ifdef HAVE_LAPACK
728  else if (ctype==CT_LIBLINEAR)
729  ((CLibLinear*) classifier)->set_C(svm_C1, svm_C2);
730 #endif
731  else if (ctype==CT_SVMLIN)
732  ((CSVMLin*) classifier)->set_C(svm_C1, svm_C2);
733  else if (ctype==CT_SVMSGD)
734  ((CSVMSGD*) classifier)->set_C(svm_C1, svm_C2);
735  else if (ctype==CT_SUBGRADIENTSVM)
736  ((CSubGradientSVM*) classifier)->set_C(svm_C1, svm_C2);
737 
738  else if (ctype==CT_LPM || ctype==CT_LPBOOST)
739  {
740  if (trainfeatures->get_feature_class()!=C_SPARSE ||
741  trainfeatures->get_feature_type()!=F_DREAL)
742  SG_ERROR("LPM and LPBOOST require trainfeatures of class SPARSE type REAL.\n");
743  }
744 
745  ((CLinearMachine*) classifier)->set_labels(trainlabels);
746  ((CLinearMachine*) classifier)->set_features((CSimpleFeatures<float64_t>*) trainfeatures);
747  result=((CLinearMachine*) classifier)->train();
748 
749  return result;
750 }
751 
753 {
754  CFeatures* trainfeatures=ui->ui_features->get_train_features();
755  CLabels* trainlabels=ui->ui_labels->get_train_labels();
756 
757  bool result=false;
758 
759  if (!trainfeatures)
760  SG_ERROR("No trainfeatures available.\n");
761 
762  if (trainfeatures->get_feature_class()!=C_STRING ||
763  trainfeatures->get_feature_type()!=F_BYTE )
764  SG_ERROR("Trainfeatures are not of class STRING type BYTE.\n");
765 
766  if (!trainlabels)
767  SG_ERROR("No labels available.\n");
768 
769  ((CWDSVMOcas*) classifier)->set_labels(trainlabels);
770  ((CWDSVMOcas*) classifier)->set_features((CStringFeatures<uint8_t>*) trainfeatures);
771  result=((CWDSVMOcas*) classifier)->train();
772 
773  return result;
774 }
775 
776 bool CGUIClassifier::load(char* filename, char* type)
777 {
778  bool result=false;
779 
780  if (new_classifier(type))
781  {
782  FILE* model_file=fopen(filename, "r");
783 
784  if (model_file)
785  {
786  if (classifier && classifier->load(model_file))
787  {
788  SG_DEBUG("file successfully read.\n");
789  result=true;
790  }
791  else
792  SG_ERROR("SVM/Classifier creation/loading failed on file %s.\n", filename);
793 
794  fclose(model_file);
795  }
796  else
797  SG_ERROR("Opening file %s failed.\n", filename);
798 
799  return result;
800  }
801  else
802  SG_ERROR("Type %s of SVM/Classifier unknown.\n", type);
803 
804  return false;
805 }
806 
807 bool CGUIClassifier::save(char* param)
808 {
809  bool result=false;
810  param=SGIO::skip_spaces(param);
811 
812  if (classifier)
813  {
814  FILE* file=fopen(param, "w");
815 
816  if ((!file) || (!classifier->save(file)))
817  printf("writing to file %s failed!\n", param);
818  else
819  {
820  printf("successfully written classifier into \"%s\" !\n", param);
821  result=true;
822  }
823 
824  if (file)
825  fclose(file);
826  }
827  else
828  SG_ERROR("create classifier first\n");
829 
830  return result;
831 }
832 
834  float64_t learnrate, int32_t maxiter)
835 {
836  if (learnrate<=0)
838  else
839  perceptron_learnrate=learnrate;
840 
841  if (maxiter<=0)
842  perceptron_maxiter=1000;
843  else
844  perceptron_maxiter=maxiter;
845  SG_INFO("Setting to perceptron parameters (learnrate %f and maxiter: %d\n", perceptron_learnrate, perceptron_maxiter);
846 
847  return true;
848 }
849 
851 {
852  if (epsilon<0)
853  svm_epsilon=1e-4;
854  else
855  svm_epsilon=epsilon;
856  SG_INFO("Set to svm_epsilon=%f.\n", svm_epsilon);
857 
858  return true;
859 }
860 
862 {
863  if (max>0)
864  {
865  max_train_time=max;
866  SG_INFO("Set to max_train_time=%f.\n", max_train_time);
867  }
868  else
869  SG_INFO("Disabling max_train_time.\n");
870 
871  return true;
872 }
873 
875 {
876  if (!classifier)
877  SG_ERROR("No regression method allocated\n");
878 
882  {
883  SG_ERROR("Underlying method not capable of SV-regression\n");
884  }
885 
886  if (tube_epsilon<0)
887  svm_tube_epsilon=1e-2;
888  svm_tube_epsilon=tube_epsilon;
889 
890  ((CSVM*) classifier)->set_tube_epsilon(svm_tube_epsilon);
891  SG_INFO("Set to svr_tube_epsilon=%f.\n", svm_tube_epsilon);
892 
893  return true;
894 }
895 
897 {
898  if (nu<0 || nu>1)
899  nu=0.5;
900 
901  svm_nu=nu;
902  SG_INFO("Set to nu=%f.\n", svm_nu);
903 
904  return true;
905 }
906 
908  float64_t weight_epsilon, float64_t C, float64_t norm)
909 {
910  if (weight_epsilon<0)
911  weight_epsilon=1e-4;
912  if (C<0)
913  C=0;
914  if (norm<0)
915  SG_ERROR("MKL norm >= 0\n");
916 
917  svm_weight_epsilon=weight_epsilon;
918  C_mkl=C;
919  mkl_norm=norm;
920 
921  SG_INFO("Set to weight_epsilon=%f.\n", svm_weight_epsilon);
922  SG_INFO("Set to C_mkl=%f.\n", C_mkl);
923  SG_INFO("Set to mkl_norm=%f.\n", mkl_norm);
924 
925  return true;
926 }
927 
929 {
930  if (lambda<0 || lambda>1)
931  SG_ERROR("0 <= ent_lambda <= 1\n");
932 
933  ent_lambda = lambda;
934  return true;
935 }
936 
938 {
939  if (mkl_bnorm<1)
940  SG_ERROR("1 <= mkl_block_norm <= inf\n");
941 
942  mkl_block_norm=mkl_bnorm;
943  return true;
944 }
945 
946 
948 {
949  if (C1<0)
950  svm_C1=1.0;
951  else
952  svm_C1=C1;
953 
954  if (C2<0)
955  svm_C2=svm_C1;
956  else
957  svm_C2=C2;
958 
959  SG_INFO("Set to C1=%f C2=%f.\n", svm_C1, svm_C2);
960 
961  return true;
962 }
963 
964 bool CGUIClassifier::set_svm_qpsize(int32_t qpsize)
965 {
966  if (qpsize<2)
967  svm_qpsize=41;
968  else
969  svm_qpsize=qpsize;
970  SG_INFO("Set qpsize to svm_qpsize=%d.\n", svm_qpsize);
971 
972  return true;
973 }
974 
975 bool CGUIClassifier::set_svm_max_qpsize(int32_t max_qpsize)
976 {
977  if (max_qpsize<50)
978  svm_max_qpsize=50;
979  else
980  svm_max_qpsize=max_qpsize;
981  SG_INFO("Set max qpsize to svm_max_qpsize=%d.\n", svm_max_qpsize);
982 
983  return true;
984 }
985 
986 bool CGUIClassifier::set_svm_bufsize(int32_t bufsize)
987 {
988  if (svm_bufsize<0)
989  svm_bufsize=3000;
990  else
991  svm_bufsize=bufsize;
992  SG_INFO("Set bufsize to svm_bufsize=%d.\n", svm_bufsize);
993 
994  return true ;
995 }
996 
998 {
999  svm_use_shrinking=enabled;
1000  if (svm_use_shrinking)
1001  SG_INFO("Enabling shrinking optimization.\n");
1002  else
1003  SG_INFO("Disabling shrinking optimization.\n");
1004 
1005  return true;
1006 }
1007 
1009 {
1010  svm_use_batch_computation=enabled;
1012  SG_INFO("Enabling batch computation.\n");
1013  else
1014  SG_INFO("Disabling batch computation.\n");
1015 
1016  return true;
1017 }
1018 
1020 {
1021  svm_use_linadd=enabled;
1022  if (svm_use_linadd)
1023  SG_INFO("Enabling LINADD optimization.\n");
1024  else
1025  SG_INFO("Disabling LINADD optimization.\n");
1026 
1027  return true;
1028 }
1029 
1031 {
1032  svm_use_bias=enabled;
1033  if (svm_use_bias)
1034  SG_INFO("Enabling svm bias.\n");
1035  else
1036  SG_INFO("Disabling svm bias.\n");
1037 
1038  return true;
1039 }
1040 
1042 {
1043  mkl_use_interleaved=enabled;
1044  if (mkl_use_interleaved)
1045  SG_INFO("Enabling mkl interleaved optimization.\n");
1046  else
1047  SG_INFO("Disabling mkl interleaved optimization.\n");
1048 
1049  return true;
1050 }
1051 
1053 {
1054  svm_do_auc_maximization=do_auc;
1055 
1057  SG_INFO("Enabling AUC maximization.\n");
1058  else
1059  SG_INFO("Disabling AUC maximization.\n");
1060 
1061  return true;
1062 }
1063 
1064 
1066 {
1067  ASSERT(classifier);
1068 
1069  switch (classifier->get_classifier_type())
1070  {
1071  case CT_LIGHT:
1072  case CT_LIGHTONECLASS:
1073  case CT_LIBSVM:
1074  case CT_SCATTERSVM:
1075  case CT_MPD:
1076  case CT_GPBT:
1077  case CT_CPLEXSVM:
1078  case CT_GMNPSVM:
1079  case CT_GNPPSVM:
1080  case CT_LIBSVR:
1081  case CT_LIBSVMMULTICLASS:
1082  case CT_LIBSVMONECLASS:
1083  case CT_SVRLIGHT:
1084  case CT_MKLCLASSIFICATION:
1085  case CT_MKLMULTICLASS:
1086  case CT_MKLREGRESSION:
1087  case CT_MKLONECLASS:
1088  case CT_KRR:
1089  return classify_kernelmachine();
1090  case CT_KNN:
1091  return classify_distancemachine();
1092  case CT_PERCEPTRON:
1093  case CT_LDA:
1094  return classify_linear();
1095  case CT_SVMLIN:
1096  case CT_SVMPERF:
1097  case CT_SUBGRADIENTSVM:
1098  case CT_SVMOCAS:
1099  case CT_SVMSGD:
1100  case CT_LPM:
1101  case CT_LPBOOST:
1102  case CT_SUBGRADIENTLPM:
1103  case CT_LIBLINEAR:
1104  return classify_linear();
1105  case CT_WDSVMOCAS:
1106  return classify_byte_linear();
1107  default:
1108  SG_ERROR("unknown classifier type\n");
1109  break;
1110  };
1111 
1112  return false;
1113 }
1114 
1116 {
1117  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1118  CFeatures* testfeatures=ui->ui_features->get_test_features();
1119 
1120  if (!classifier)
1121  SG_ERROR("No kernelmachine available.\n");
1122 
1123  bool success=true;
1124 
1125  if (ui->ui_kernel->get_kernel()->get_kernel_type()!=K_CUSTOM)
1126  {
1127  if (ui->ui_kernel->get_kernel()->get_kernel_type()==K_COMBINED
1128  && ( !trainfeatures || !testfeatures ))
1129  {
1130  SG_DEBUG("skipping initialisation of combined kernel "
1131  "as train/test features are unavailable\n");
1132  }
1133  else
1134  {
1135  if (!trainfeatures)
1136  SG_ERROR("No training features available.\n");
1137  if (!testfeatures)
1138  SG_ERROR("No test features available.\n");
1139 
1140  success=ui->ui_kernel->init_kernel("TEST");
1141  }
1142  }
1143 
1144  if (!success || !ui->ui_kernel->is_initialized())
1145  SG_ERROR("Kernel not initialized.\n");
1146 
1148  km->set_kernel(ui->ui_kernel->get_kernel());
1150 
1151  SG_INFO("Starting kernel machine testing.\n");
1152  return classifier->apply();
1153 }
1154 
1156  float64_t* &weights, int32_t &rows, int32_t &cols, float64_t*& bias,
1157  int32_t& brows, int32_t& bcols,
1158  int32_t idx) // which SVM for MultiClass
1159 {
1160  ASSERT(classifier);
1161 
1162  switch (classifier->get_classifier_type())
1163  {
1164  case CT_SCATTERSVM:
1165  case CT_GNPPSVM:
1166  case CT_LIBSVMMULTICLASS:
1167  case CT_LIGHT:
1168  case CT_LIGHTONECLASS:
1169  case CT_LIBSVM:
1170  case CT_MPD:
1171  case CT_GPBT:
1172  case CT_CPLEXSVM:
1173  case CT_GMNPSVM:
1174  case CT_LIBSVR:
1175  case CT_LIBSVMONECLASS:
1176  case CT_SVRLIGHT:
1177  case CT_MKLCLASSIFICATION:
1178  case CT_MKLREGRESSION:
1179  case CT_MKLONECLASS:
1180  case CT_MKLMULTICLASS:
1181  case CT_KRR:
1182  return get_svm(weights, rows, cols, bias, brows, bcols, idx);
1183  break;
1184  case CT_PERCEPTRON:
1185  case CT_LDA:
1186  case CT_LPM:
1187  case CT_LPBOOST:
1188  case CT_SUBGRADIENTLPM:
1189  case CT_SVMOCAS:
1190  case CT_SVMSGD:
1191  case CT_SVMLIN:
1192  case CT_SVMPERF:
1193  case CT_SUBGRADIENTSVM:
1194  case CT_LIBLINEAR:
1195  return get_linear(weights, rows, cols, bias, brows, bcols);
1196  break;
1197  case CT_KMEANS:
1198  case CT_HIERARCHICAL:
1199  return get_clustering(weights, rows, cols, bias, brows, bcols);
1200  break;
1201  case CT_KNN:
1202  SG_ERROR("not implemented");
1203  break;
1204  default:
1205  SG_ERROR("unknown classifier type\n");
1206  break;
1207  };
1208  return false;
1209 }
1210 
1211 
1213 {
1214  ASSERT(classifier);
1215  return ((CMultiClassSVM*) classifier)->get_num_svms();
1216 }
1217 
1219  float64_t* &weights, int32_t& rows, int32_t& cols, float64_t*& bias,
1220  int32_t& brows, int32_t& bcols, int32_t idx)
1221 {
1222  CSVM* svm=(CSVM*) classifier;
1223 
1224  if (idx>-1) // should be MultiClassSVM
1225  svm=((CMultiClassSVM*) svm)->get_svm(idx);
1226 
1227  if (svm)
1228  {
1229  brows=1;
1230  bcols=1;
1231  bias=SG_MALLOC(float64_t, 1);
1232  *bias=svm->get_bias();
1233 
1234  rows=svm->get_num_support_vectors();
1235  cols=2;
1236  weights=SG_MALLOC(float64_t, rows*cols);
1237 
1238  for (int32_t i=0; i<rows; i++)
1239  {
1240  weights[i]=svm->get_alpha(i);
1241  weights[i+rows]=svm->get_support_vector(i);
1242  }
1243 
1244  return true;
1245  }
1246 
1247  return false;
1248 }
1249 
1251  float64_t* &centers, int32_t& rows, int32_t& cols, float64_t*& radi,
1252  int32_t& brows, int32_t& bcols)
1253 {
1254  if (!classifier)
1255  return false;
1256 
1257  switch (classifier->get_classifier_type())
1258  {
1259  case CT_KMEANS:
1260  {
1261  CKMeans* clustering=(CKMeans*) classifier;
1262 
1263  bcols=1;
1264  SGVector<float64_t> r=clustering->get_radiuses();
1265  brows=r.vlen;
1266  radi=SG_MALLOC(float64_t, brows);
1267  memcpy(radi, r.vector, sizeof(float64_t)*brows);
1268 
1269  cols=1;
1270  SGMatrix<float64_t> c=clustering->get_cluster_centers();
1271  rows=c.num_rows;
1272  cols=c.num_cols;
1273  centers=SG_MALLOC(float64_t, rows*cols);
1274  memcpy(centers, c.matrix, sizeof(float64_t)*rows*cols);
1275  break;
1276  }
1277 
1278  case CT_HIERARCHICAL:
1279  {
1280  CHierarchical* clustering=(CHierarchical*) classifier;
1281 
1282  // radi == merge_distances, centers == pairs
1283  bcols=1;
1284  SGVector<float64_t> r=clustering->get_merge_distances();
1285  brows=r.vlen;
1286  radi=SG_MALLOC(float64_t, brows);
1287  memcpy(radi, r.vector, sizeof(float64_t)*brows);
1288 
1289  SGMatrix<int32_t> p=clustering->get_cluster_pairs();
1290  rows=p.num_rows;
1291  cols=p.num_cols;
1292  centers=SG_MALLOC(float64_t, rows*cols);
1293  for (int32_t i=0; i<rows*cols; i++)
1294  centers[i]=(float64_t) p.matrix[i];
1295 
1296  break;
1297  }
1298 
1299  default:
1300  SG_ERROR("internal error - unknown clustering type\n");
1301  }
1302 
1303  return true;
1304 }
1305 
1307  float64_t* &weights, int32_t& rows, int32_t& cols, float64_t*& bias,
1308  int32_t& brows, int32_t& bcols)
1309 {
1311 
1312  if (!linear)
1313  return false;
1314 
1315  bias=SG_MALLOC(float64_t, 1);
1316  *bias=linear->get_bias();
1317  brows=1;
1318  bcols=1;
1319 
1320  cols=1;
1321  float64_t* w=NULL;
1322  linear->get_w(w, rows);
1323 
1324  weights= SG_MALLOC(float64_t, rows);
1325  memcpy(weights, w, sizeof(float64_t)*rows);
1326 
1327  return true;
1328 }
1329 
1331 {
1332  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1333  CFeatures* testfeatures=ui->ui_features->get_test_features();
1334 
1335  if (!classifier)
1336  {
1337  SG_ERROR("no kernelmachine available\n") ;
1338  return NULL;
1339  }
1340  if (!trainfeatures)
1341  {
1342  SG_ERROR("no training features available\n") ;
1343  return NULL;
1344  }
1345 
1346  if (!testfeatures)
1347  {
1348  SG_ERROR("no test features available\n") ;
1349  return NULL;
1350  }
1351 
1352  bool success=ui->ui_distance->init_distance("TEST");
1353 
1354  if (!success || !ui->ui_distance->is_initialized())
1355  {
1356  SG_ERROR("distance not initialized\n") ;
1357  return NULL;
1358  }
1359 
1360  ((CDistanceMachine*) classifier)->set_distance(
1361  ui->ui_distance->get_distance());
1362  SG_INFO("starting distance machine testing\n") ;
1363  return classifier->apply();
1364 }
1365 
1366 
1368 {
1369  CFeatures* testfeatures=ui->ui_features->get_test_features();
1370 
1371  if (!classifier)
1372  {
1373  SG_ERROR("no classifier available\n") ;
1374  return NULL;
1375  }
1376  if (!testfeatures)
1377  {
1378  SG_ERROR("no test features available\n") ;
1379  return NULL;
1380  }
1381  if (!(testfeatures->has_property(FP_DOT)))
1382  {
1383  SG_ERROR("testfeatures not based on DotFeatures\n") ;
1384  return false ;
1385  }
1386 
1387  ((CLinearMachine*) classifier)->set_features((CDotFeatures*) testfeatures);
1388  SG_INFO("starting linear classifier testing\n") ;
1389  return classifier->apply();
1390 }
1391 
1393 {
1394  CFeatures* testfeatures=ui->ui_features->get_test_features();
1395 
1396  if (!classifier)
1397  {
1398  SG_ERROR("no svm available\n") ;
1399  return NULL;
1400  }
1401  if (!testfeatures)
1402  {
1403  SG_ERROR("no test features available\n") ;
1404  return NULL;
1405  }
1406  if (testfeatures->get_feature_class() != C_STRING ||
1407  testfeatures->get_feature_type() != F_BYTE )
1408  {
1409  SG_ERROR("testfeatures not of class STRING type BYTE\n") ;
1410  return false ;
1411  }
1412 
1413  ((CWDSVMOcas*) classifier)->set_features((CStringFeatures<uint8_t>*) testfeatures);
1414  SG_INFO("starting linear classifier testing\n") ;
1415  return classifier->apply();
1416 }
1417 
1419 {
1420  CFeatures* trainfeatures=ui->ui_features->get_train_features();
1421  CFeatures* testfeatures=ui->ui_features->get_test_features();
1422 
1423  if (!classifier)
1424  {
1425  SG_ERROR("no svm available\n") ;
1426  return false;
1427  }
1428 
1429  if (!ui->ui_kernel->is_initialized())
1430  {
1431  SG_ERROR("kernel not initialized\n") ;
1432  return false;
1433  }
1434 
1435  if (!ui->ui_kernel->get_kernel() ||
1436  !ui->ui_kernel->get_kernel()->get_kernel_type()==K_CUSTOM)
1437  {
1438  if (!trainfeatures)
1439  {
1440  SG_ERROR("no training features available\n") ;
1441  return false;
1442  }
1443 
1444  if (!testfeatures)
1445  {
1446  SG_ERROR("no test features available\n") ;
1447  return false;
1448  }
1449  }
1450 
1451  ((CKernelMachine*) classifier)->set_kernel(
1452  ui->ui_kernel->get_kernel());
1453 
1454  result=classifier->apply(idx);
1455  return true ;
1456 }
1457 
1458 
1460 {
1461 #ifdef HAVE_LAPACK
1462  krr_tau=tau;
1463  ((CKRR*) classifier)->set_tau(krr_tau);
1464  SG_INFO("Set to krr_tau=%f.\n", krr_tau);
1465 
1466  return true;
1467 #else
1468  return false;
1469 #endif
1470 }
1471 
1472 bool CGUIClassifier::set_solver(char* solver)
1473 {
1474  ESolverType s=ST_AUTO;
1475 
1476  if (strncmp(solver,"NEWTON", 6)==0)
1477  {
1478  SG_INFO("Using NEWTON solver.\n");
1479  s=ST_NEWTON;
1480  }
1481  else if (strncmp(solver,"DIRECT", 6)==0)
1482  {
1483  SG_INFO("Using DIRECT solver\n");
1484  s=ST_DIRECT;
1485  }
1486  else if (strncmp(solver,"BLOCK_NORM", 9)==0)
1487  {
1488  SG_INFO("Using BLOCK_NORM solver\n");
1489  s=ST_BLOCK_NORM;
1490  }
1491  else if (strncmp(solver,"ELASTICNET", 10)==0)
1492  {
1493  SG_INFO("Using ELASTICNET solver\n");
1494  s=ST_ELASTICNET;
1495  }
1496  else if (strncmp(solver,"AUTO", 4)==0)
1497  {
1498  SG_INFO("Automagically determining solver.\n");
1499  s=ST_AUTO;
1500  }
1501 #ifdef USE_CPLEX
1502  else if (strncmp(solver, "CPLEX", 5)==0)
1503  {
1504  SG_INFO("USING CPLEX METHOD selected\n");
1505  s=ST_CPLEX;
1506  }
1507 #endif
1508 #ifdef USE_GLPK
1509  else if (strncmp(solver,"GLPK", 4)==0)
1510  {
1511  SG_INFO("Using GLPK solver\n");
1512  s=ST_GLPK;
1513  }
1514 #endif
1515  else
1516  SG_ERROR("Unknown solver type, %s (not compiled in?)\n", solver);
1517 
1518 
1519  solver_type=s;
1520  return true;
1521 }
1522 
1524 {
1525  if (strcmp(name,"LIBSVM_ONECLASS")==0)
1526  {
1529  SG_INFO("created SVMlibsvm object for oneclass\n");
1530  }
1531  else if (strcmp(name,"LIBSVM_MULTICLASS")==0)
1532  {
1535  SG_INFO("created SVMlibsvm object for multiclass\n");
1536  }
1537  else if (strcmp(name,"LIBSVM_NUMULTICLASS")==0)
1538  {
1540  constraint_generator= new CLibSVMMultiClass(LIBSVM_NU_SVC);
1541  SG_INFO("created SVMlibsvm object for multiclass\n") ;
1542  }
1543  else if (strcmp(name,"SCATTERSVM_RULE1")==0)
1544  {
1547  SG_INFO("created ScatterSVM RULE1 object\n") ;
1548  }
1549  else if (strcmp(name,"SCATTERSVM_RULE2")==0)
1550  {
1553  SG_INFO("created ScatterSVM RULE2 object\n") ;
1554  }
1555  else if (strcmp(name,"LIBSVM_NU")==0)
1556  {
1558  constraint_generator= new CLibSVM(LIBSVM_NU_SVC);
1559  SG_INFO("created SVMlibsvm object\n") ;
1560  }
1561  else if (strcmp(name,"LIBSVM")==0)
1562  {
1565  SG_INFO("created SVMlibsvm object\n") ;
1566  }
1567  else if (strcmp(name,"LARANK")==0)
1568  {
1571  SG_INFO("created LaRank object\n") ;
1572  }
1573 
1574  else if (strcmp(name,"GPBTSVM")==0)
1575  {
1578  SG_INFO("created GPBT-SVM object\n") ;
1579  }
1580  else if (strcmp(name,"MPDSVM")==0)
1581  {
1584  SG_INFO("created MPD-SVM object\n") ;
1585  }
1586  else if (strcmp(name,"GNPPSVM")==0)
1587  {
1590  SG_INFO("created GNPP-SVM object\n") ;
1591  }
1592  else if (strcmp(name,"GMNPSVM")==0)
1593  {
1596  SG_INFO("created GMNP-SVM object\n") ;
1597  }
1598  else if (strcmp(name,"LIBSVR")==0)
1599  {
1602  SG_INFO("created SVRlibsvm object\n") ;
1603  }
1604  else
1605  {
1606  SG_ERROR("Unknown SV-classifier %s.\n", name);
1607  return false;
1608  }
1610 
1611  return (constraint_generator!=NULL);
1612 }

SHOGUN Machine Learning Toolbox - Documentation