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

Function make_dataset

dlib/test/active_learning.cpp:26–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24// ----------------------------------------------------------------------------------------
25
26 void make_dataset (
27 std::vector<sample_type>& samples,
28 std::vector<double>& labels
29 )
30 {
31 for (int r = -10; r <= 10; ++r)
32 {
33 for (int c = -10; c <= 10; ++c)
34 {
35 sample_type samp(2);
36 samp(0) = r;
37 samp(1) = c;
38 samples.push_back(samp);
39
40 // if this point is less than 10 from the origin
41 if (sqrt((double)r*r + c*c) <= 8)
42 labels.push_back(+1);
43 else
44 labels.push_back(-1);
45
46 }
47 }
48
49
50 vector_normalizer<sample_type> normalizer;
51 normalizer.train(samples);
52 for (unsigned long i = 0; i < samples.size(); ++i)
53 samples[i] = normalizer(samples[i]);
54
55 randomize_samples(samples, labels);
56
57 /*
58 cout << "samples.size(): " << samples.size() << endl;
59 cout << "num +1 samples: "<< sum(mat(labels) > 0) << endl;
60 cout << "num -1 samples: "<< sum(mat(labels) < 0) << endl;
61 */
62
63 empirical_kernel_map<kernel_type> ekm;
64 ekm.load(kernel_type(0.15), samples);
65 for (unsigned long i = 0; i < samples.size(); ++i)
66 samples[i] = ekm.project(samples[i]);
67
68 //cout << "dims: "<< ekm.out_vector_size() << endl;
69 }
70
71// ----------------------------------------------------------------------------------------
72

Callers 1

perform_testMethod · 0.70

Calls 6

randomize_samplesFunction · 0.85
sqrtFunction · 0.50
push_backMethod · 0.45
trainMethod · 0.45
sizeMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected