Algorithm-SVM
view release on metacpan or search on metacpan
{
if (!be_shrunken(active_size, Gmax1, Gmax2))
{
swap_index(i,active_size);
break;
}
active_size--;
}
}
// unshrink, check all variables again before final iterations
if(unshrinked || Gmax1 + Gmax2 > eps*10) return;
unshrinked = true;
reconstruct_gradient();
for(i=l-1;i>=active_size;i--)
if (!be_shrunken(i, Gmax1, Gmax2))
{
while (active_size < i)
{
if (!be_shrunken(active_size, Gmax1, Gmax2, Gmax3, Gmax4))
{
swap_index(i,active_size);
break;
}
active_size--;
}
}
// unshrink, check all variables again before final iterations
if(unshrinked || max(Gmax1+Gmax2,Gmax3+Gmax4) > eps*10) return;
unshrinked = true;
reconstruct_gradient();
for(i=l-1;i>=active_size;i--)
if (!be_shrunken(i, Gmax1, Gmax2, Gmax3, Gmax4))
{
while (active_size < i)
int l, const double *dec_values, const double *labels,
double& A, double& B)
{
double prior1=0, prior0 = 0;
int i;
for (i=0;i<l;i++)
if (labels[i] > 0) prior1+=1;
else prior0+=1;
int max_iter=100; // Maximal number of iterations
double min_step=1e-10; // Minimal step taken in line search
double sigma=1e-12; // For numerically strict PD of Hessian
double eps=1e-5;
double hiTarget=(prior1+1.0)/(prior1+2.0);
double loTarget=1/(prior0+2.0);
double *t=Malloc(double,l);
double fApB,p,q,h11,h22,h21,g1,g2,det,dA,dB,gd,stepsize;
double newA,newB,newf,d1,d2;
int iter;
}
if (stepsize < min_step)
{
info("Line search fails in two-class probability estimates\n");
break;
}
}
if (iter>=max_iter)
info("Reaching maximal iterations in two-class probability estimates\n");
free(t);
}
double sigmoid_predict(double decision_value, double A, double B)
{
double fApB = decision_value*A+B;
if (fApB >= 0)
return exp(-fApB)/(1.0+exp(-fApB));
else
return 1.0/(1+exp(fApB)) ;
( run in 0.616 second using v1.01-cache-2.11-cpan-96521ef73a4 )