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

Function dense_model_scikit

src/thundersvm/thundersvm-scikit.cpp:145–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143 }
144
145 void dense_model_scikit(int row_size, int features, float* data, float* label,
146 int svm_type, int kernel_type, int degree, float gamma, float coef0,
147 float cost, float nu, float epsilon, float tol, int probability,
148 int weight_size, int* weight_label, float* weight,
149 int verbose, int max_iter, int n_cores, int max_mem_size,
150 int gpu_id,
151 int* n_features, int* n_classes, int* succeed, SvmModel* model){
152
153#ifdef USE_CUDA
154 CUDA_CHECK(cudaSetDevice(gpu_id));
155#endif
156
157 succeed[0] = 1;
158 if(verbose)
159 el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Enabled, "true");
160 else
161 el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Enabled, "false");
162
163 if (n_cores > 0) {
164 omp_set_num_threads(n_cores);
165 } else if (n_cores != -1) {
166 LOG(ERROR) << "n_jobs must be positive or -1";
167 }
168
169 DataSet train_dataset;
170 train_dataset.load_from_dense(row_size, features, data, label);
171// SvmModel* model;
172// switch (svm_type){
173// case SvmParam::C_SVC:
174// model = new SVC();
175// break;
176// case SvmParam::NU_SVC:
177// model = new NuSVC();
178// break;
179// case SvmParam::ONE_CLASS:
180// model = new OneClassSVC();
181// break;
182// case SvmParam::EPSILON_SVR:
183// model = new SVR();
184// break;
185// case SvmParam::NU_SVR:
186// model = new NuSVR();
187// break;
188// }
189
190 model->set_max_iter(max_iter);
191 //todo add this to check_parameter method
192 if (svm_type == SvmParam::NU_SVC) {
193 train_dataset.group_classes();
194 for (int i = 0; i < train_dataset.n_classes(); ++i) {
195 int n1 = train_dataset.count()[i];
196 for (int j = i + 1; j < train_dataset.n_classes(); ++j) {
197 int n2 = train_dataset.count()[j];
198 if (nu * (n1 + n2) / 2 > min(n1, n2)) {
199 printf("specified nu is infeasible\n");
200 succeed[0] = -1;
201 }
202 }

Callers

nothing calls this directly

Calls 9

minFunction · 0.85
maxFunction · 0.85
load_from_denseMethod · 0.80
set_max_iterMethod · 0.80
group_classesMethod · 0.80
n_classesMethod · 0.80
get_n_classesMethod · 0.80
trainMethod · 0.45
n_featuresMethod · 0.45

Tested by

no test coverage detected