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

Method model_setup

src/thundersvm/model/svc.cpp:16–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14using std::stringstream;
15
16void SVC::model_setup(const DataSet &dataset, SvmParam &param) {
17
18 //group instances with same class
19 n_classes = dataset.n_classes();
20 LOG(INFO) << "#classes = " << n_classes;
21 this->label = dataset.label();
22 SvmModel::model_setup(dataset, param);
23 this->param.svm_type = SvmParam::C_SVC;
24 //calculate class weight for each class
25 c_weight = vector<float_type>(n_classes, 1);
26 for (int i = 0; i < param.nr_weight; ++i) {
27 bool found = false;
28 for (int j = 0; j < n_classes; ++j) {
29 if (param.weight_label[i] == dataset.label()[j]) {
30 found = true;
31 c_weight[j] *= param.weight[i];
32 break;
33 }
34 }
35 if (!found)
36 LOG(WARNING) << "weighted label " << param.weight_label[i] << " not found";
37 }
38
39}
40
41void SVC::train(const DataSet &dataset, SvmParam param) {
42 DataSet dataset_ = dataset;

Callers

nothing calls this directly

Calls 1

n_classesMethod · 0.80

Tested by

no test coverage detected