MCPcopy Create free account
hub / github.com/davisking/dlib / unittest_binary_classification

Function unittest_binary_classification

dlib/test/svm.cpp:488–627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486// ----------------------------------------------------------------------------------------
487
488 void unittest_binary_classification (
489 )
490 /*!
491 ensures
492 - runs tests on the svm stuff compliance with the specs
493 !*/
494 {
495 dlog << LINFO << " begin unittest_binary_classification()";
496 print_spinner();
497
498
499 typedef double scalar_type;
500 typedef matrix<scalar_type,2,1> sample_type;
501
502 std::vector<sample_type> x;
503 std::vector<matrix<double,0,1> > x_linearized;
504 std::vector<scalar_type> y;
505
506 get_checkerboard_problem(x,y, 300, 2);
507 const scalar_type gamma = 1;
508
509 typedef radial_basis_kernel<sample_type> kernel_type;
510
511 rbf_network_trainer<kernel_type> rbf_trainer;
512 rbf_trainer.set_kernel(kernel_type(gamma));
513 rbf_trainer.set_num_centers(100);
514
515 rvm_trainer<kernel_type> rvm_trainer;
516 rvm_trainer.set_kernel(kernel_type(gamma));
517
518 krr_trainer<kernel_type> krr_trainer;
519 krr_trainer.use_classification_loss_for_loo_cv();
520 krr_trainer.set_kernel(kernel_type(gamma));
521
522 svm_pegasos<kernel_type> pegasos_trainer;
523 pegasos_trainer.set_kernel(kernel_type(gamma));
524 pegasos_trainer.set_lambda(0.00001);
525
526
527 svm_c_ekm_trainer<kernel_type> ocas_ekm_trainer;
528 ocas_ekm_trainer.set_kernel(kernel_type(gamma));
529 ocas_ekm_trainer.set_c(100000);
530
531 svm_nu_trainer<kernel_type> trainer;
532 trainer.set_kernel(kernel_type(gamma));
533 trainer.set_nu(0.05);
534
535 svm_c_trainer<kernel_type> c_trainer;
536 c_trainer.set_kernel(kernel_type(gamma));
537 c_trainer.set_c(100);
538
539 svm_c_linear_trainer<linear_kernel<matrix<double,0,1> > > lin_trainer;
540 lin_trainer.set_c(100000);
541 // use an ekm to linearize this dataset so we can use it with the lin_trainer
542 empirical_kernel_map<kernel_type> ekm;
543 ekm.load(kernel_type(gamma), x);
544 for (unsigned long i = 0; i < x.size(); ++i)
545 x_linearized.push_back(ekm.project(x[i]));

Callers 1

perform_testMethod · 0.85

Calls 15

print_spinnerFunction · 0.85
get_checkerboard_problemFunction · 0.85
cross_validate_trainerFunction · 0.85
randomly_subsampleFunction · 0.85
absFunction · 0.85
meanFunction · 0.85
set_num_centersMethod · 0.80
batchFunction · 0.50
batch_cachedFunction · 0.50
sumFunction · 0.50

Tested by

no test coverage detected