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

Class SVRTest

src/test/test_svr.cpp:9–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected