26 LIBSVR_SOLVER_TYPE st)
34 case LIBSVR_EPSILON_SVR:
41 SG_ERROR(
"CLibSVR::CLibSVR(): Unknown solver type!\n");
54 void CLibSVR::register_params()
68 struct svm_model* model =
nullptr;
77 SG_ERROR(
"Number of training vectors does not match number of labels\n")
83 struct svm_node* x_space;
86 SG_INFO(
"%d trainlabels\n", problem.l)
88 problem.y=SG_MALLOC(
float64_t, problem.l);
89 problem.x=SG_MALLOC(
struct svm_node*, problem.l);
90 x_space=SG_MALLOC(
struct svm_node, 2*problem.l);
92 for (int32_t i=0; i<problem.l; i++)
95 problem.x[i]=&x_space[2*i];
97 x_space[2*i+1].index=-1;
100 int32_t weights_label[2]={-1,+1};
105 case LIBSVR_EPSILON_SVR:
106 param.svm_type=EPSILON_SVR;
109 param.svm_type=NU_SVR;
116 param.kernel_type = LINEAR;
129 param.weight_label = weights_label;
130 param.weight = weights;
133 const char* error_msg = svm_check_parameter(&problem,¶m);
138 model = svm_train(&problem, ¶m);
142 ASSERT(model->nr_class==2)
143 ASSERT((model->l==0) || (model->l>0 && model->SV && model->sv_coef && model->sv_coef[0]))
145 int32_t num_sv=model->l;
153 for (int32_t i=0; i<num_sv; i++)
163 svm_destroy_model(model);
virtual bool init(CFeatures *lhs, CFeatures *rhs)
virtual bool train_machine(CFeatures *data=NULL)
virtual ELabelType get_label_type() const =0
Real Labels are real-valued labels.
The class Labels models labels, i.e. class assignments of objects.
virtual int32_t get_num_labels() const =0
real valued labels (e.g. for regression, classifier outputs)
virtual int32_t get_num_vectors() const =0
float64_t m_max_train_time
int32_t cache_size
cache_size in MB
void set_nu(float64_t nue)
virtual EMachineType get_classifier_type()
void set_bias(float64_t bias)
bool set_alpha(int32_t idx, float64_t val)
void set_objective(float64_t v)
virtual const char * get_name() const
bool set_support_vector(int32_t idx, int32_t val)
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
LIBSVR_SOLVER_TYPE solver_type
A generic Support Vector Machine Interface.
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_tube_epsilon(float64_t eps)