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

Function train_R

src/thundersvm/svm_R_interface.cpp:133–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131// }
132
133 int* train_R(char** dataset, int* kernel, int* svm_type,
134 int* degree, char** gamma, double* coef0,
135 double* nu, double* cost, double* epsilon,
136 double* tol, int* probability,
137 char** class_weight, int* weight_length,int* n_fold,
138 int* verbose, int* max_iter, int* n_cores, char **model_file){
139 int* succeed = new int[1];
140 succeed[0] = 1;
141
142 if(*verbose)
143 el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Enabled, "false");
144 else
145 el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Enabled, "true");
146
147 if (n_cores[0] > 0) {
148 omp_set_num_threads(n_cores[0]);
149 } else if (n_cores[0] != -1) {
150 LOG(ERROR) << "n_cores must be positive or -1";
151 }
152
153 char input_file_path[1024] = DATASET_DIR;
154 char model_file_path[1024] = DATASET_DIR;
155 strcat(input_file_path, "../R/");
156 strcat(model_file_path, "../R/");
157 strcpy(input_file_path, dataset[0]);
158 if(strcmp(model_file[0], "None") == 0) {
159 strcpy(model_file_path, dataset[0]);
160 strcat(model_file_path, ".model");
161 }
162 else
163 strcpy(model_file_path, model_file[0]);
164 DataSet train_dataset;
165 train_dataset.load_from_file(input_file_path);
166 SvmModel* model;
167 switch (*svm_type){
168 case SvmParam::C_SVC:
169 model = new SVC();
170 break;
171 case SvmParam::NU_SVC:
172 model = new NuSVC();
173 break;
174 case SvmParam::ONE_CLASS:
175 model = new OneClassSVC();
176 break;
177 case SvmParam::EPSILON_SVR:
178 model = new SVR();
179 break;
180 case SvmParam::NU_SVR:
181 model = new NuSVR();
182 break;
183 }
184 model->set_max_iter(*max_iter);
185 //todo add this to check_parameter method
186 if (*svm_type == SvmParam::NU_SVC) {
187 train_dataset.group_classes();
188 for (int i = 0; i < train_dataset.n_classes(); ++i) {
189 int n1 = train_dataset.count()[i];
190 for (int j = i + 1; j < train_dataset.n_classes(); ++j) {

Callers

nothing calls this directly

Calls 11

minFunction · 0.85
set_max_iterMethod · 0.80
group_classesMethod · 0.80
n_classesMethod · 0.80
cross_validationMethod · 0.80
nameMethod · 0.80
scoreMethod · 0.80
load_from_fileMethod · 0.45
n_featuresMethod · 0.45
trainMethod · 0.45
save_to_fileMethod · 0.45

Tested by

no test coverage detected