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

Method perform_test

dlib/test/elastic_net.cpp:84–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82 }
83
84 void perform_test (
85 )
86 {
87 matrix<double> w = {1,2,0,4, 0,0,0,0,0, 6, 7,8,0, 9, 0};
88
89 matrix<double> X = randm(w.size(),1000);
90 matrix<double> Y = trans(X)*w;
91 Y += 0.1*(randm(Y.nr(), Y.nc())-0.5);
92
93
94 double ridge_lambda = 0.1;
95 double lasso_budget = sum(abs(w));
96 double eps = 0.0000001;
97
98 dlib::elastic_net solver(X*trans(X),X*Y);
99 solver.set_epsilon(eps);
100
101
102 matrix<double,0,1> results;
103 matrix<double,0,1> results2;
104 for (double s = 1.2; s > 0.10; s *= 0.9)
105 {
106 print_spinner();
107 dlog << LINFO << "s: "<< s;
108 // make sure the two solvers agree.
109 results = basic_elastic_net(X, Y, ridge_lambda, lasso_budget*s, eps);
110 results2 = solver(ridge_lambda, lasso_budget*s);
111 dlog << LINFO << "error: "<< max(abs(results - results2));
112 DLIB_TEST(max(abs(results - results2)) < 1e-3);
113 }
114 }
115 } a;
116
117// ----------------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 11

absFunction · 0.85
print_spinnerFunction · 0.85
basic_elastic_netFunction · 0.85
randmFunction · 0.70
transFunction · 0.50
sumFunction · 0.50
maxFunction · 0.50
sizeMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45
set_epsilonMethod · 0.45

Tested by

no test coverage detected