55 "Tube epsilon for support vector regression.",
MS_AVAILABLE);
93 char char_buffer[1024];
96 int32_t line_number=1;
100 if (fscanf(modelfl,
"%4s\n", char_buffer)==EOF)
103 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
108 if (strcmp(
"%SVM", char_buffer)!=0)
111 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
117 if (fscanf(modelfl,
" numsv=%d; \n", &int_buffer) != 1)
120 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
126 SG_INFO(
"loading %ld support vectors\n",int_buffer)
129 if (fscanf(modelfl,
" kernel='%s'; \n", char_buffer) != 1)
132 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
140 if (fscanf(modelfl,
" b=%lf; \n", &double_buffer) != 1)
143 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
151 if (fscanf(modelfl,
"%8s\n", char_buffer) == EOF)
154 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
159 if (strcmp(
"alphas=[", char_buffer)!=0)
162 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
172 if (fscanf(modelfl,
" \[%lf,%d]; \n", &double_buffer, &int_buffer) != 2)
175 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
185 if (fscanf(modelfl,
"%2s", char_buffer) == EOF)
188 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
193 if (strcmp(
"];", char_buffer)!=0)
196 SG_ERROR(
"error in svm file, line nr:%d\n", line_number)
213 SG_INFO(
"Writing model file...")
214 fprintf(modelfl,
"%%SVM\n");
217 fprintf(modelfl,
"b=%+10.16e;\n",
get_bias());
219 fprintf(modelfl,
"alphas=\[\n");
222 fprintf(modelfl,
"\t[%+10.16e,%d];\n",
225 fprintf(modelfl,
"];\n");
249 for (int32_t i=0; i<n; i++)
254 for (int32_t j=0; j<n; j++)
262 SG_ERROR(
"cannot compute objective, labels or kernel not set\n")
283 for (int32_t i=0; i<n; i++)
286 for (int32_t j=0; j<n; j++)
297 SG_ERROR(
"cannot compute objective, labels or kernel not set\n")
299 return regularizer+loss;
319 SG_ERROR(
"Please assign labels first!\n")
323 if (num_labels != linear_term.
vlen)
325 SG_ERROR(
"Number of labels (%d) does not match number"
326 "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
int32_t get_num_support_vectors()
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.
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)
bool set_alpha(int32_t idx, float64_t val)
virtual SGVector< float64_t > get_linear_term()
float64_t get_alpha(int32_t idx)
bool use_batch_computation
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)
Binary Labels for binary classification.
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)