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

Function run_prior_sparse_test

dlib/test/ranking.cpp:114–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112// ----------------------------------------------------------------------------------------
113
114 void run_prior_sparse_test()
115 {
116 print_spinner();
117 typedef std::map<unsigned long,double> sample_type;
118 typedef sparse_linear_kernel<sample_type> kernel_type;
119
120 svm_rank_trainer<kernel_type> trainer;
121
122 ranking_pair<sample_type> data;
123
124 sample_type samp;
125 samp[0] = 1; data.relevant.push_back(samp); samp.clear();
126 samp[1] = 1; data.nonrelevant.push_back(samp); samp.clear();
127
128 trainer.set_c(10);
129 decision_function<kernel_type> df = trainer.train(data);
130
131 trainer.set_prior(df);
132
133 data.relevant.clear();
134 data.nonrelevant.clear();
135 samp[2] = 1; data.relevant.push_back(samp); samp.clear();
136 samp[1] = 1; data.nonrelevant.push_back(samp); samp.clear();
137
138 df = trainer.train(data);
139
140 matrix<double,0,1> w = sparse_to_dense(df.basis_vectors(0));
141 dlog << LINFO << trans(w);
142 DLIB_TEST(w(0) > 0.1);
143 DLIB_TEST(w(1) < -0.1);
144 DLIB_TEST(w(2) > 0.1);
145 }
146
147// ----------------------------------------------------------------------------------------
148

Callers 1

perform_testMethod · 0.70

Calls 8

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

Tested by

no test coverage detected