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

Function TEST

src/test/test_oneclass_svc.cpp:7–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include <thundersvm/model/oneclass_svc.h>
6
7TEST(OneClassSVCTest, train) {
8 DataSet dataset;
9 dataset.load_from_file(DATASET_DIR "test_dataset.txt");
10 SvmParam param;
11 param.gamma = 0.5;
12 param.nu = 0.1;
13 param.epsilon = 0.001;
14 param.kernel_type = SvmParam::RBF;
15 param.svm_type = SvmParam::ONE_CLASS;
16 SvmModel *model = new OneClassSVC();
17 model->train(dataset, param);
18 model->save_to_file(DATASET_DIR "test_dataset.txt.model");
19 SvmModel *new_model = new OneClassSVC();
20 new_model->load_from_file(DATASET_DIR "test_dataset.txt.model");
21 vector<float_type> predict_y = new_model->predict(dataset.instances(), 100);
22 int n_pos = 0;
23 for (unsigned i = 0; i < predict_y.size(); ++i) {
24 if (predict_y[i] > 0)
25 n_pos++;
26 }
27 EXPECT_EQ(n_pos, 135);
28 delete model;
29 delete new_model;
30}

Callers

nothing calls this directly

Calls 6

instancesMethod · 0.80
load_from_fileMethod · 0.45
trainMethod · 0.45
save_to_fileMethod · 0.45
predictMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected