mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Added some tests for the svm_pegasos object.
--HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402911
This commit is contained in:
parent
d95195cb2c
commit
299377a86b
@ -341,6 +341,11 @@ namespace
|
||||
rvm_trainer<kernel_type> rvm_trainer;
|
||||
rvm_trainer.set_kernel(kernel_type(gamma));
|
||||
|
||||
svm_pegasos<kernel_type> pegasos_trainer;
|
||||
pegasos_trainer.set_kernel(kernel_type(gamma));
|
||||
pegasos_trainer.set_lambda(0.00001);
|
||||
|
||||
|
||||
svm_nu_trainer<kernel_type> trainer;
|
||||
trainer.set_kernel(kernel_type(gamma));
|
||||
trainer.set_nu(0.05);
|
||||
@ -352,14 +357,18 @@ namespace
|
||||
print_spinner();
|
||||
matrix<scalar_type> rbf_cv = cross_validate_trainer_threaded(rbf_trainer, x,y, 4, 2);
|
||||
print_spinner();
|
||||
matrix<scalar_type> peg_cv = cross_validate_trainer_threaded(batch(pegasos_trainer,1.0), x,y, 4, 2);
|
||||
print_spinner();
|
||||
|
||||
dlog << LDEBUG << "rvm cv: " << rvm_cv;
|
||||
dlog << LDEBUG << "svm cv: " << svm_cv;
|
||||
dlog << LDEBUG << "rbf cv: " << rbf_cv;
|
||||
dlog << LDEBUG << "peg cv: " << peg_cv;
|
||||
|
||||
DLIB_CASSERT(mean(rvm_cv) > 0.9, rvm_cv);
|
||||
DLIB_CASSERT(mean(svm_cv) > 0.9, svm_cv);
|
||||
DLIB_CASSERT(mean(rbf_cv) > 0.9, rbf_cv);
|
||||
DLIB_CASSERT(mean(peg_cv) > 0.9, rbf_cv);
|
||||
|
||||
const long num_sv = trainer.train(x,y).support_vectors.size();
|
||||
print_spinner();
|
||||
|
Loading…
Reference in New Issue
Block a user