42 SG_ERROR(
"Number of training vectors does not match number of labels\n")
50 const int64_t maxiter = 1L<<30;
87 for (int32_t i=0; i<n; i++)
105 bool free_alpha=
false;
111 for (int32_t i=0; i<n; i++)
115 if (alphas[i] > 0 && alphas[i] < d)
118 if ( (dalphas[i]==0) ||
119 (alphas[i]==0 && dalphas[i] >0) ||
120 (alphas[i]==d && dalphas[i] <0)
129 else if (v == maxpviol)
136 if (maxpidx<0 || maxdviol<0)
137 SG_ERROR(
"no violation no convergence, should not happen!\n")
145 if (niter%10000 == 0)
149 for (int32_t i=0; i<n; i++)
152 for (int32_t j=0; j<n; j++)
156 SG_DEBUG(
"obj:%f pviol:%f dviol:%f maxpidx:%d iter:%d\n", obj, maxpviol, maxdviol, maxpidx, niter)
162 primalcool = (maxpviol < primaleps*stopfac);
163 dualcool = (maxdviol < dualeps*stopfac) || (!free_alpha);
166 if (primalcool && dualcool)
169 SG_INFO(
" no free alpha, stopping! #iter=%d\n", niter)
171 SG_INFO(
" done! #iter=%d\n", niter)
176 ASSERT(maxpidx>=0 && maxpidx<n)
178 hstep=-hessres[maxpidx]/
compute_H(maxpidx,maxpidx);
182 hessest-=F[maxpidx]*hstep;
189 if (tmpalpha > d-alpha_eps)
192 if (tmpalpha < 0+alpha_eps)
196 float64_t alphachange = tmpalpha - alphas[maxpidx];
197 alphas[maxpidx] = tmpalpha;
200 for (int32_t i=0; i<n; i++)
202 hessres[i]+=h[i]*hstep;
205 dalphas[i] +=h[i]*alphachange;
209 detas+=F[maxpidx]*alphachange;
224 for (int32_t i=0; i<n; i++)
225 dalphas[i]+= F[i] * etachange;
230 if (niter >= maxiter)
235 for (int32_t i=0; i<n; i++)
247 for (int32_t i=0; i<n; i++)
virtual bool init(CFeatures *lhs, CFeatures *rhs)
int32_t get_num_support_vectors()
virtual ELabelType get_label_type() const =0
The class Labels models labels, i.e. class assignments of objects.
virtual int32_t get_num_labels() const =0
virtual int32_t get_num_vectors() const =0
float64_t kernel(int32_t idx_a, int32_t idx_b)
void unlock_kernel_row(int32_t i)
float64_t compute_H(int32_t i, int32_t j)
KERNELCACHE_ELEM * lock_kernel_row(int32_t i)
float64_t compute_svm_dual_objective()
bool is_cached(int64_t number)
virtual bool train_machine(CFeatures *data=NULL)
void set_bias(float64_t bias)
CCache< KERNELCACHE_ELEM > * kernel_cache
static void clear_cancel()
bool set_alpha(int32_t idx, float64_t val)
bool set_support_vector(int32_t idx, int32_t val)
static bool cancel_computations()
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
A generic Support Vector Machine Interface.
Binary Labels for binary classification.
virtual bool has_features()
float64_t get_objective()
float64_t KERNELCACHE_ELEM
bool create_new_model(int32_t num)