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

Function unittest_binary_classification

dlib/test/svm.cpp:391–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389// ----------------------------------------------------------------------------------------
390
391 void unittest_binary_classification (
392 )
393 /*!
394 ensures
395 - runs tests on the svm stuff compliance with the specs
396 !*/
397 {
398 dlog << LINFO << " begin unittest_binary_classification()";
399 print_spinner();
400
401
402 typedef double scalar_type;
403 typedef matrix<scalar_type,2,1> sample_type;
404
405 std::vector<sample_type> x;
406 std::vector<matrix<double,0,1> > x_linearized;
407 std::vector<scalar_type> y;
408
409 get_checkerboard_problem(x,y, 300, 2);
410 const scalar_type gamma = 1;
411
412 typedef radial_basis_kernel<sample_type> kernel_type;
413
414 rbf_network_trainer<kernel_type> rbf_trainer;
415 rbf_trainer.set_kernel(kernel_type(gamma));
416 rbf_trainer.set_num_centers(100);
417
418 rvm_trainer<kernel_type> rvm_trainer;
419 rvm_trainer.set_kernel(kernel_type(gamma));
420
421 krr_trainer<kernel_type> krr_trainer;
422 krr_trainer.use_classification_loss_for_loo_cv();
423 krr_trainer.set_kernel(kernel_type(gamma));
424
425 svm_pegasos<kernel_type> pegasos_trainer;
426 pegasos_trainer.set_kernel(kernel_type(gamma));
427 pegasos_trainer.set_lambda(0.00001);
428
429
430 svm_c_ekm_trainer<kernel_type> ocas_ekm_trainer;
431 ocas_ekm_trainer.set_kernel(kernel_type(gamma));
432 ocas_ekm_trainer.set_c(100000);
433
434 svm_nu_trainer<kernel_type> trainer;
435 trainer.set_kernel(kernel_type(gamma));
436 trainer.set_nu(0.05);
437
438 svm_c_trainer<kernel_type> c_trainer;
439 c_trainer.set_kernel(kernel_type(gamma));
440 c_trainer.set_c(100);
441
442 svm_c_linear_trainer<linear_kernel<matrix<double,0,1> > > lin_trainer;
443 lin_trainer.set_c(100000);
444 // use an ekm to linearize this dataset so we can use it with the lin_trainer
445 empirical_kernel_map<kernel_type> ekm;
446 ekm.load(kernel_type(gamma), x);
447 for (unsigned long i = 0; i < x.size(); ++i)
448 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