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

Function run_prior_test

dlib/test/ranking.cpp:80–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78// ----------------------------------------------------------------------------------------
79
80 void run_prior_test()
81 {
82 print_spinner();
83 typedef matrix<double,3,1> sample_type;
84 typedef linear_kernel<sample_type> kernel_type;
85
86 svm_rank_trainer<kernel_type> trainer;
87
88 ranking_pair<sample_type> data;
89
90 sample_type samp;
91 samp = 0, 0, 1; data.relevant.push_back(samp);
92 samp = 0, 1, 0; data.nonrelevant.push_back(samp);
93
94 trainer.set_c(10);
95 decision_function<kernel_type> df = trainer.train(data);
96
97 trainer.set_prior(df);
98
99 data.relevant.clear();
100 data.nonrelevant.clear();
101 samp = 1, 0, 0; data.relevant.push_back(samp);
102 samp = 0, 1, 0; data.nonrelevant.push_back(samp);
103
104 df = trainer.train(data);
105
106 dlog << LINFO << trans(df.basis_vectors(0));
107 DLIB_TEST(df.basis_vectors(0)(0) > 0);
108 DLIB_TEST(df.basis_vectors(0)(1) < 0);
109 DLIB_TEST(df.basis_vectors(0)(2) > 0);
110 }
111
112// ----------------------------------------------------------------------------------------
113

Callers 1

perform_testMethod · 0.70

Calls 7

print_spinnerFunction · 0.85
transFunction · 0.50
push_backMethod · 0.45
set_cMethod · 0.45
trainMethod · 0.45
set_priorMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected