MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / benchmark_nb

Function benchmark_nb

examples/machine_learning/naive_bayes.cpp:80–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void benchmark_nb(const array &train_feats, const array test_feats,
81 const array &train_labels, int num_classes) {
82 array mu, sig2;
83 int iter = 25;
84 float *priors = new float[num_classes];
85
86 timer::start();
87 for (int i = 0; i < iter; i++) {
88 naive_bayes_train(priors, mu, sig2, train_feats, train_labels,
89 num_classes);
90 }
91 af::sync();
92 printf("Training time: %4.4lf s\n", timer::stop() / iter);
93
94 timer::start();
95 for (int i = 0; i < iter; i++) {
96 naive_bayes_predict(priors, mu, sig2, test_feats, num_classes);
97 }
98 af::sync();
99 printf("Prediction time: %4.4lf s\n", timer::stop() / iter);
100
101 delete[] priors;
102}
103
104void naive_bayes_demo(bool console, int perc) {
105 array train_images, train_labels;

Callers 1

naive_bayes_demoFunction · 0.85

Calls 3

naive_bayes_trainFunction · 0.85
naive_bayes_predictFunction · 0.85
syncFunction · 0.50

Tested by

no test coverage detected