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

Function sparse_model_scikit

src/thundersvm/thundersvm-scikit.cpp:41–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 }
40
41 void sparse_model_scikit(int row_size, float* val, int* row_ptr, int* col_ptr, float* label,
42 int svm_type, int kernel_type, int degree, float gamma, float coef0,
43 float cost, float nu, float epsilon, float tol, int probability,
44 int weight_size, int* weight_label, float* weight,
45 int verbose, int max_iter, int n_cores, int max_mem_size,
46 int gpu_id,
47 int* n_features, int* n_classes, int* succeed, SvmModel* model){
48#ifdef USE_CUDA
49 CUDA_CHECK(cudaSetDevice(gpu_id));
50#endif
51
52 succeed[0] = 1;
53 if(verbose)
54 el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Enabled, "true");
55 else
56 el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Enabled, "false");
57
58 if (n_cores > 0) {
59 omp_set_num_threads(n_cores);
60 } else if (n_cores != -1) {
61 LOG(ERROR) << "n_jobs must be positive or -1";
62 }
63
64 DataSet train_dataset;
65 train_dataset.load_from_sparse(row_size, val, row_ptr, col_ptr, label);
66// SvmModel* model;
67// switch (svm_type){
68// case SvmParam::C_SVC:
69// model = new SVC();
70// break;
71// case SvmParam::NU_SVC:
72// model = new NuSVC();
73// break;
74// case SvmParam::ONE_CLASS:
75// model = new OneClassSVC();
76// break;
77// case SvmParam::EPSILON_SVR:
78// model = new SVR();
79// break;
80// case SvmParam::NU_SVR:
81// model = new NuSVR();
82// break;
83// }
84 model->set_max_iter(max_iter);
85
86 //todo add this to check_parameter method
87 if (svm_type == SvmParam::NU_SVC) {
88 train_dataset.group_classes();
89 for (int i = 0; i < train_dataset.n_classes(); ++i) {
90 int n1 = train_dataset.count()[i];
91 for (int j = i + 1; j < train_dataset.n_classes(); ++j) {
92 int n2 = train_dataset.count()[j];
93 if (nu * (n1 + n2) / 2 > min(n1, n2)) {
94 printf("specified nu is infeasible\n");
95 succeed[0] = -1;
96 }
97 }
98 }

Callers

nothing calls this directly

Calls 9

minFunction · 0.85
maxFunction · 0.85
load_from_sparseMethod · 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