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

Function thundersvm_predict_sub

src/thundersvm/svm_interface_api.cpp:114–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112 return;
113 }
114 void thundersvm_predict_sub(DataSet& predict_dataset, CMDParser& parser, char* model_file_path, char* output_file_path){
115 fstream file;
116 file.open(model_file_path, std::fstream::in);
117 string feature, svm_type;
118 file >> feature >> svm_type;
119 CHECK_EQ(feature, "svm_type");
120 SvmModel *model = nullptr;
121 Metric *metric = nullptr;
122 if (svm_type == "c_svc") {
123 model = new SVC();
124 metric = new Accuracy();
125 } else if (svm_type == "nu_svc") {
126 model = new NuSVC();
127 metric = new Accuracy();
128 } else if (svm_type == "one_class") {
129 model = new OneClassSVC();
130 //todo determine a metric
131 } else if (svm_type == "epsilon_svr") {
132 model = new SVR();
133 metric = new MSE();
134 } else if (svm_type == "nu_svr") {
135 model = new NuSVR();
136 metric = new MSE();
137 }
138
139#ifdef USE_CUDA
140 CUDA_CHECK(cudaSetDevice(parser.gpu_id));
141#endif
142
143 model->set_max_memory_size_Byte(parser.param_cmd.max_mem_size);
144 model->load_from_file(model_file_path);
145 file.close();
146 file.open(output_file_path, fstream::out);
147
148 vector<float_type> predict_y;
149 predict_y = model->predict(predict_dataset.instances(), -1);
150 for (int i = 0; i < predict_y.size(); ++i) {
151 file << predict_y[i] << std::endl;
152 }
153 file.close();
154
155 if (metric) {
156 LOG(INFO) << metric->name() << " = " << metric->score(predict_y, predict_dataset.y());
157 }
158 }
159
160 void thundersvm_predict(int argc, char **argv){
161 CMDParser parser;

Callers 2

thundersvm_predictFunction · 0.85

Calls 7

instancesMethod · 0.80
nameMethod · 0.80
scoreMethod · 0.80
load_from_fileMethod · 0.45
predictMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected