51 "Tube epsilon for support vector regression.",
MS_AVAILABLE);
88 char char_buffer[1024];
91 int32_t line_number=1;
95 if (fscanf(modelfl,
"%4s\n", char_buffer)==EOF)
98 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
103 if (strcmp(
"%SVM", char_buffer)!=0)
106 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
112 if (fscanf(modelfl,
" numsv=%d; \n", &int_buffer) != 1)
115 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
121 SG_INFO(
"loading %ld support vectors\n",int_buffer)
124 if (fscanf(modelfl,
" kernel='%s'; \n", char_buffer) != 1)
127 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
135 if (fscanf(modelfl,
" b=%lf; \n", &double_buffer) != 1)
138 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
146 if (fscanf(modelfl,
"%8s\n", char_buffer) == EOF)
149 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
154 if (strcmp(
"alphas=[", char_buffer)!=0)
157 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
167 if (fscanf(modelfl,
" \[%lf,%d]; \n", &double_buffer, &int_buffer) != 2)
170 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
180 if (fscanf(modelfl,
"%2s", char_buffer) == EOF)
183 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
188 if (strcmp(
"];", char_buffer)!=0)
191 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
208 SG_INFO(
"Writing model file...")
209 fprintf(modelfl,
"%%SVM\n");
212 fprintf(modelfl,
"b=%+10.16e;\n",
get_bias());
214 fprintf(modelfl,
"alphas=\[\n");
217 fprintf(modelfl,
"\t[%+10.16e,%d];\n",
220 fprintf(modelfl,
"];\n");
244 for (int32_t i=0; i<n; i++)
249 for (int32_t j=0; j<n; j++)
257 SG_ERROR(
"cannot compute objective, labels or kernel not set\n")
278 for (int32_t i=0; i<n; i++)
281 for (int32_t j=0; j<n; j++)
292 SG_ERROR(
"cannot compute objective, labels or kernel not set\n")
294 return regularizer+loss;
314 SG_ERROR(
"Please assign labels first!\n")
318 if (num_labels != linear_term.
vlen)
320 SG_ERROR(
"Number of labels (%d) does not match number" 321 "of entries (%d) in linear term \n", num_labels, linear_term.
vlen);
virtual float64_t apply_one(int32_t num)
virtual const char * get_name() const =0
void set_shrinking_enabled(bool enable)
int32_t get_num_support_vectors()
void set_bias_enabled(bool enable_bias)
float64_t compute_svm_primal_objective()
The class Labels models labels, i.e. class assignments of objects.
virtual int32_t get_num_labels() const =0
bool(* callback)(CMKL *mkl, const float64_t *sumw, const float64_t suma)
void set_callback_function(CMKL *m, bool(*cb)(CMKL *mkl, const float64_t *sumw, const float64_t suma))
float64_t kernel(int32_t idx_a, int32_t idx_b)
virtual void set_linear_term(const SGVector< float64_t > linear_term)
A generic KernelMachine interface.
void set_nu(float64_t nue)
virtual float64_t * get_linear_term_array()
void set_defaults(int32_t num_sv=0)
SGVector< float64_t > m_linear_term
float64_t compute_svm_dual_objective()
Class SGObject is the base class of all shogun objects.
void set_bias(float64_t bias)
void set_batch_computation_enabled(bool enable)
bool set_alpha(int32_t idx, float64_t val)
void set_objective(float64_t v)
void set_qpsize(int32_t qps)
virtual SGVector< float64_t > get_linear_term()
float64_t get_alpha(int32_t idx)
bool set_support_vector(int32_t idx, int32_t val)
Multiple Kernel Learning.
int32_t get_support_vector(int32_t idx)
bool load(FILE *svm_file)
all of classes and functions are contained in the shogun namespace
bool save(FILE *svm_file)
void set_linadd_enabled(bool enable)
Binary Labels for binary classification.
void set_epsilon(float64_t eps)
void set_kernel(CKernel *k)
virtual void set_labels(CLabels *lab)
void set_C(float64_t c_neg, float64_t c_pos)
bool create_new_model(int32_t num)
void set_loaded_status(bool loaded)
void set_tube_epsilon(float64_t eps)