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

Function test_svm_trainer2

dlib/test/svm.cpp:686–731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

684// ----------------------------------------------------------------------------------------
685
686 void test_svm_trainer2()
687 {
688 typedef matrix<double, 2, 1> sample_type;
689 typedef linear_kernel<sample_type> kernel_type;
690
691
692 std::vector<sample_type> samples;
693 std::vector<double> labels;
694
695 sample_type samp;
696 samp(0) = 1;
697 samp(1) = 1;
698 samples.push_back(samp);
699 labels.push_back(+1);
700
701 samp(0) = 1;
702 samp(1) = 2;
703 samples.push_back(samp);
704 labels.push_back(-1);
705
706 svm_c_trainer<kernel_type> trainer;
707
708 decision_function<kernel_type> df = trainer.train(samples, labels);
709
710 samp(0) = 1;
711 samp(1) = 1;
712 dlog << LINFO << "test +1 : "<< df(samp);
713 DLIB_TEST(df(samp) > 0);
714 samp(0) = 1;
715 samp(1) = 2;
716 dlog << LINFO << "test -1 : "<< df(samp);
717 DLIB_TEST(df(samp) < 0);
718
719 svm_nu_trainer<kernel_type> trainer2;
720 df = trainer2.train(samples, labels);
721
722 samp(0) = 1;
723 samp(1) = 1;
724 dlog << LINFO << "test +1 : "<< df(samp);
725 DLIB_TEST(df(samp) > 0);
726 samp(0) = 1;
727 samp(1) = 2;
728 dlog << LINFO << "test -1 : "<< df(samp);
729 DLIB_TEST(df(samp) < 0);
730
731 }
732
733// ----------------------------------------------------------------------------------------
734

Callers 1

perform_testMethod · 0.85

Calls 2

push_backMethod · 0.45
trainMethod · 0.45

Tested by

no test coverage detected