MCPcopy Create free account
hub / github.com/Xtra-Computing/thundersvm / SVCTest

Class SVCTest

src/test/test_svc.cpp:8–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include <thundersvm/util/metric.h>
7
8class SVCTest : public ::testing::Test {
9protected:
10 SVCTest() : test_dataset() {}
11
12 DataSet train_dataset;
13 DataSet test_dataset;
14 SvmParam param;
15 vector<float_type> predict_y;
16
17 float load_dataset_and_train(string train_filename, string test_filename, float_type C, float_type gamma) {
18 train_dataset.load_from_file(train_filename);
19 test_dataset.load_from_file(test_filename);
20 param.gamma = gamma;
21 param.C = C;
22 param.kernel_type = SvmParam::RBF;
23 std::shared_ptr<SvmModel> model;
24 model.reset(new SVC());
25 model->train(train_dataset, param);
26 std::shared_ptr<Metric> metric;
27 metric.reset(new Accuracy());
28 predict_y = model->predict(test_dataset.instances(), 100);
29 return metric->score(predict_y, test_dataset.y());
30 }
31};
32
33TEST_F(SVCTest, test_set) {
34 EXPECT_NEAR(load_dataset_and_train(DATASET_DIR

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected