15 using namespace shogun;
16 #define INDEX(ROW,COL,DIM) (((COL)*(DIM))+(ROW))
40 SG_ERROR(
"Number of training vectors does not match number of labels\n");
45 SG_INFO(
"%d trainlabels\n", num_data);
48 for (int32_t i=0; i<num_data; i++)
59 int32_t tmax=1000000000;
68 for(int32_t i=0; i<num_data; i++) {
74 memset(vector_c, 0, num_data*
sizeof(
float64_t));
84 npp.
gnpp_imdm(diagK, vector_c, vector_y, num_data,
85 tmax, tolabs, tolrel, thlb, alpha, &t, &aHa11, &aHa22,
92 for(int32_t i = 0; i < num_data; i++ )
94 if( alpha[i] != 0 ) num_sv++;
97 alpha[i] = alpha[i]*2/nconst;
98 if( alpha[i]/(2*C) >= 1 ) trnerr++;
102 alpha[i] = -alpha[i]*2/nconst;
103 if( alpha[i]/(2*C) <= -1 ) trnerr++;
107 float64_t b = 0.5*(aHa22 - aHa11)/nconst;;
114 for (int32_t i=0; i<num_data; i++)
virtual bool init(CFeatures *lhs, CFeatures *rhs)
virtual float64_t get_label(int32_t i)
The class Labels models labels, i.e. class assignments of objects.
class GNPPLib, a Library of solvers for Generalized Nearest Point Problem (GNPP). ...
virtual int32_t get_num_vectors() const =0
float64_t kernel(int32_t idx_a, int32_t idx_b)
#define INDEX(ROW, COL, DIM)
void set_bias(float64_t bias)
bool set_alpha(int32_t idx, float64_t val)
void set_objective(float64_t v)
virtual CLabels * get_labels()
bool set_support_vector(int32_t idx, int32_t val)
The class Features is the base class of all feature objects.
A generic Support Vector Machine Interface.
int8_t gnpp_imdm(float64_t *diag_H, float64_t *vector_c, float64_t *vector_y, int32_t dim, int32_t tmax, float64_t tolabs, float64_t tolrel, float64_t th, float64_t *alpha, int32_t *ptr_t, float64_t *ptr_aHa11, float64_t *ptr_aHa22, float64_t **ptr_History, int32_t verb)
virtual bool train_machine(CFeatures *data=NULL)
#define SG_MALLOC(type, len)
bool create_new_model(int32_t num)