Go to the documentation of this file.
15 template <
class T>
static inline T
min(T
x,T y) {
return (
x<y)?
x:y; }
18 template <
class T>
static inline T
max(T
x,T y) {
return (
x>y)?
x:y; }
20 template <
class T>
static inline void swap(T&
x, T& y) { T t=
x;
x=y; y=t; }
21 template <
class S,
class T>
static inline void clone(T*& dst, S* src,
int n)
24 memcpy((
void *)dst,(
void *)src,
sizeof(T)*n);
26 static inline double powi(
double base,
int times)
28 double tmp = base, ret = 1.0;
30 for(
int t=times; t>0; t/=2)
39 #define Malloc(type,n) (type *)malloc((n)*sizeof(type))
48 static void info(
const char *fmt,...)
55 (*svm_print_string)(buf);
58 static void info(
const char *fmt,...) {}
130 int more = len - h->
len;
173 swap(h->data[i],h->data[j]);
196 virtual Qfloat *
get_Q(
int column,
int len)
const = 0;
197 virtual double *
get_QD()
const = 0;
198 virtual void swap_index(
int i,
int j)
const = 0;
209 virtual Qfloat *
get_Q(
int column,
int len)
const = 0;
210 virtual double *
get_QD()
const = 0;
233 return dot(
x[i],
x[j]);
249 return x[i][(int)(
x[j][0].value)].
value;
254 :kernel_type(
param.kernel_type), degree(
param.degree),
358 while(y->
index != -1)
407 double *alpha_,
double Cp,
double Cn,
double eps,
428 return (
y[i] > 0)?
Cp :
Cn;
434 else if(
alpha[i] <= 0)
447 bool be_shrunk(
int i,
double Gmax1,
double Gmax2);
479 info(
"\nWARNING: using -h 0 may be faster\n");
488 G[i] +=
alpha[j] * Q_i[j];
497 double alpha_i =
alpha[i];
499 G[j] += alpha_i * Q_i[j];
505 double *alpha_,
double Cp,
double Cn,
double eps,
548 double alpha_i =
alpha[i];
551 G[j] += alpha_i*Q_i[j];
561 int max_iter =
max(10000000,
l>INT_MAX/100 ? INT_MAX : 100*
l);
562 int counter =
min(
l,1000)+1;
564 while(iter < max_iter)
570 counter =
min(
l,1000);
596 double C_i =
get_C(i);
597 double C_j =
get_C(j);
599 double old_alpha_i =
alpha[i];
600 double old_alpha_j =
alpha[j];
604 double quad_coef =
QD[i]+
QD[j]+2*Q_i[j];
607 double delta = (-
G[i]-
G[j])/quad_coef;
633 alpha[j] = C_i - diff;
641 alpha[i] = C_j + diff;
647 double quad_coef =
QD[i]+
QD[j]-2*Q_i[j];
650 double delta = (
G[i]-
G[j])/quad_coef;
660 alpha[j] = sum - C_i;
676 alpha[i] = sum - C_j;
691 double delta_alpha_i =
alpha[i] - old_alpha_i;
692 double delta_alpha_j =
alpha[j] - old_alpha_j;
696 G[k] += Q_i[k]*delta_alpha_i + Q_j[k]*delta_alpha_j;
712 G_bar[k] -= C_i * Q_i[k];
715 G_bar[k] += C_i * Q_i[k];
723 G_bar[k] -= C_j * Q_j[k];
726 G_bar[k] += C_j * Q_j[k];
740 info(
"\nWARNING: reaching max number of iterations");
774 info(
"\noptimization finished, #iter = %d\n",iter);
798 double obj_diff_min =
INF;
831 double grad_diff=Gmax+
G[j];
837 double quad_coef =
QD[i]+
QD[j]-2.0*
y[i]*Q_i[j];
839 obj_diff = -(grad_diff*grad_diff)/quad_coef;
841 obj_diff = -(grad_diff*grad_diff)/
TAU;
843 if (obj_diff <= obj_diff_min)
846 obj_diff_min = obj_diff;
855 double grad_diff= Gmax-
G[j];
861 double quad_coef =
QD[i]+
QD[j]+2.0*
y[i]*Q_i[j];
863 obj_diff = -(grad_diff*grad_diff)/quad_coef;
865 obj_diff = -(grad_diff*grad_diff)/
TAU;
867 if (obj_diff <= obj_diff_min)
870 obj_diff_min = obj_diff;
890 return(-
G[i] > Gmax1);
892 return(-
G[i] > Gmax2);
897 return(
G[i] > Gmax2);
899 return(
G[i] > Gmax1);
970 double ub =
INF, lb = -
INF, sum_free = 0;
973 double yG =
y[i]*
G[i];
997 r = sum_free/nr_free;
1024 bool be_shrunk(
int i,
double Gmax1,
double Gmax2,
double Gmax3,
double Gmax4);
1037 double Gmaxp = -
INF;
1038 double Gmaxp2 = -
INF;
1041 double Gmaxn = -
INF;
1042 double Gmaxn2 = -
INF;
1046 double obj_diff_min =
INF;
1070 const Qfloat *Q_ip = NULL;
1071 const Qfloat *Q_in = NULL;
1083 double grad_diff=Gmaxp+
G[j];
1089 double quad_coef =
QD[ip]+
QD[j]-2*Q_ip[j];
1091 obj_diff = -(grad_diff*grad_diff)/quad_coef;
1093 obj_diff = -(grad_diff*grad_diff)/
TAU;
1095 if (obj_diff <= obj_diff_min)
1098 obj_diff_min = obj_diff;
1107 double grad_diff=Gmaxn-
G[j];
1108 if (-
G[j] >= Gmaxn2)
1113 double quad_coef =
QD[in]+
QD[j]-2*Q_in[j];
1115 obj_diff = -(grad_diff*grad_diff)/quad_coef;
1117 obj_diff = -(grad_diff*grad_diff)/
TAU;
1119 if (obj_diff <= obj_diff_min)
1122 obj_diff_min = obj_diff;
1129 if(
max(Gmaxp+Gmaxp2,Gmaxn+Gmaxn2) <
eps)
1132 if (
y[Gmin_idx] == +1)
1146 return(-
G[i] > Gmax1);
1148 return(-
G[i] > Gmax4);
1153 return(
G[i] > Gmax2);
1155 return(
G[i] > Gmax3);
1163 double Gmax1 = -
INF;
1164 double Gmax2 = -
INF;
1165 double Gmax3 = -
INF;
1166 double Gmax4 = -
INF;
1176 if(-
G[i] > Gmax1) Gmax1 = -
G[i];
1178 else if(-
G[i] > Gmax4) Gmax4 = -
G[i];
1184 if(
G[i] > Gmax2) Gmax2 =
G[i];
1186 else if(
G[i] > Gmax3) Gmax3 =
G[i];
1198 if (
be_shrunk(i, Gmax1, Gmax2, Gmax3, Gmax4))
1215 int nr_free1 = 0,nr_free2 = 0;
1216 double ub1 =
INF, ub2 =
INF;
1217 double lb1 = -
INF, lb2 = -
INF;
1218 double sum_free1 = 0, sum_free2 = 0;
1225 lb1 =
max(lb1,
G[i]);
1227 ub1 =
min(ub1,
G[i]);
1237 lb2 =
max(lb2,
G[i]);
1239 ub2 =
min(ub2,
G[i]);
1250 r1 = sum_free1/nr_free1;
1255 r2 = sum_free2/nr_free2;
1275 for(
int i=0;i<
prob.
l;i++)
1285 for(j=
start;j<len;j++)
1324 for(
int i=0;i<
prob.
l;i++)
1334 for(j=
start;j<len;j++)
1370 QD =
new double[2*
l];
1373 for(
int k=0;k<
l;k++)
1397 int j, real_i =
index[i];
1445 double *minus_ones =
new double[l];
1454 if(
prob->
y[i] > 0) y[i] = +1;
else y[i] = -1;
1463 sum_alpha += alpha[i];
1466 info(
"nu = %f\n", sum_alpha/(Cp*
prob->
l));
1471 delete[] minus_ones;
1491 double sum_pos = nu*l/2;
1492 double sum_neg = nu*l/2;
1497 alpha[i] =
min(1.0,sum_pos);
1498 sum_pos -= alpha[i];
1502 alpha[i] =
min(1.0,sum_neg);
1503 sum_neg -= alpha[i];
1506 double *zeros =
new double[l];
1516 info(
"C = %f\n",1/r);
1535 double *zeros =
new double[l];
1567 double *alpha2 =
new double[2*l];
1568 double *linear_term =
new double[2*l];
1587 double sum_alpha = 0;
1590 alpha[i] = alpha2[i] - alpha2[i+l];
1591 sum_alpha += fabs(alpha[i]);
1596 delete[] linear_term;
1606 double *alpha2 =
new double[2*l];
1607 double *linear_term =
new double[2*l];
1611 double sum = C *
param->
nu * l / 2;
1614 alpha2[i] = alpha2[i+l] =
min(sum,C);
1617 linear_term[i] = -
prob->
y[i];
1620 linear_term[i+l] =
prob->
y[i];
1628 info(
"epsilon = %f\n",-si->
r);
1631 alpha[i] = alpha2[i] - alpha2[i+l];
1634 delete[] linear_term;
1649 double Cp,
double Cn)
1678 for(
int i=0;i<
prob->
l;i++)
1680 if(fabs(alpha[i]) > 0)
1696 info(
"nSV = %d, nBSV = %d\n",nSV,nBSV);
1706 int l,
const double *dec_values,
const double *labels,
1707 double& A,
double& B)
1709 double prior1=0, prior0 = 0;
1713 if (labels[i] > 0) prior1+=1;
1717 double min_step=1e-10;
1720 double hiTarget=(prior1+1.0)/(prior1+2.0);
1721 double loTarget=1/(prior0+2.0);
1722 double *t=
Malloc(
double,l);
1723 double fApB,p,q,h11,h22,h21,g1,g2,det,dA,dB,gd,stepsize;
1724 double newA,newB,newf,d1,d2;
1728 A=0.0; B=log((prior0+1.0)/(prior1+1.0));
1733 if (labels[i]>0) t[i]=hiTarget;
1735 fApB = dec_values[i]*A+B;
1737 fval += t[i]*fApB + log(1+exp(-fApB));
1739 fval += (t[i] - 1)*fApB +log(1+exp(fApB));
1741 for (iter=0;iter<max_iter;iter++)
1746 h21=0.0;g1=0.0;g2=0.0;
1749 fApB = dec_values[i]*A+B;
1752 p=exp(-fApB)/(1.0+exp(-fApB));
1753 q=1.0/(1.0+exp(-fApB));
1757 p=1.0/(1.0+exp(fApB));
1758 q=exp(fApB)/(1.0+exp(fApB));
1761 h11+=dec_values[i]*dec_values[i]*d2;
1763 h21+=dec_values[i]*d2;
1765 g1+=dec_values[i]*d1;
1770 if (fabs(g1)<eps && fabs(g2)<eps)
1774 det=h11*h22-h21*h21;
1775 dA=-(h22*g1 - h21 * g2) / det;
1776 dB=-(-h21*g1+ h11 * g2) / det;
1781 while (stepsize >= min_step)
1783 newA = A + stepsize * dA;
1784 newB = B + stepsize * dB;
1790 fApB = dec_values[i]*newA+newB;
1792 newf += t[i]*fApB + log(1+exp(-fApB));
1794 newf += (t[i] - 1)*fApB +log(1+exp(fApB));
1797 if (newf<fval+0.0001*stepsize*gd)
1799 A=newA;B=newB;fval=newf;
1803 stepsize = stepsize / 2.0;
1806 if (stepsize < min_step)
1808 info(
"Line search fails in two-class probability estimates\n");
1814 info(
"Reaching maximal iterations in two-class probability estimates\n");
1820 double fApB = decision_value*A+B;
1823 return exp(-fApB)/(1.0+exp(-fApB));
1825 return 1.0/(1+exp(fApB)) ;
1832 int iter = 0, max_iter=
max(100,k);
1833 double **Q=
Malloc(
double *,k);
1834 double *Qp=
Malloc(
double,k);
1835 double pQp, eps=0.005/k;
1844 Q[t][t]+=r[j][t]*r[j][t];
1849 Q[t][t]+=r[j][t]*r[j][t];
1850 Q[t][j]=-r[j][t]*r[t][j];
1853 for (iter=0;iter<max_iter;iter++)
1861 Qp[t]+=Q[t][j]*p[j];
1867 double error=fabs(Qp[t]-pQp);
1868 if (error>max_error)
1871 if (max_error<eps)
break;
1875 double diff=(-Qp[t]+pQp)/Q[t][t];
1877 pQp=(pQp+diff*(diff*Q[t][t]+2*Qp[t]))/(1+diff)/(1+diff);
1880 Qp[j]=(Qp[j]+diff*Q[t][j])/(1+diff);
1886 info(
"Exceeds max_iter in multiclass_prob\n");
1887 for(t=0;t<k;t++) free(Q[t]);
1895 double Cp,
double Cn,
double& probA,
double& probB)
1903 for(i=0;i<
prob->
l;i++) perm[i]=i;
1904 for(i=0;i<
prob->
l;i++)
1906 int j = i+rand()%(
prob->
l-i);
1907 swap(perm[i],perm[j]);
1916 subprob.
l =
prob->
l-(end-begin);
1918 subprob.y =
Malloc(
double,subprob.l);
1921 for(j=0;j<begin;j++)
1923 subprob.x[k] =
prob->
x[perm[j]];
1924 subprob.y[k] =
prob->
y[perm[j]];
1927 for(j=end;j<
prob->
l;j++)
1929 subprob.x[k] =
prob->
x[perm[j]];
1930 subprob.y[k] =
prob->
y[perm[j]];
1933 int p_count=0,n_count=0;
1940 if(p_count==0 && n_count==0)
1941 for(j=begin;j<end;j++)
1942 dec_values[perm[j]] = 0;
1943 else if(p_count > 0 && n_count == 0)
1944 for(j=begin;j<end;j++)
1945 dec_values[perm[j]] = 1;
1946 else if(p_count == 0 && n_count > 0)
1947 for(j=begin;j<end;j++)
1948 dec_values[perm[j]] = -1;
1962 for(j=begin;j<end;j++)
1966 dec_values[perm[j]] *= submodel->
label[0];
1991 for(i=0;i<
prob->
l;i++)
1993 ymv[i]=
prob->
y[i]-ymv[i];
1994 mae += fabs(ymv[i]);
1997 double std=sqrt(2*mae*mae);
2000 for(i=0;i<
prob->
l;i++)
2001 if (fabs(ymv[i]) > 5*
std)
2005 mae /= (
prob->
l-count);
2006 info(
"Prob. model for test data: target value = predicted value + z,\nz: Laplace distribution e^(-|z|/sigma)/(2sigma),sigma= %g\n",mae);
2017 int max_nr_class = 16;
2020 int *count =
Malloc(
int,max_nr_class);
2021 int *data_label =
Malloc(
int,
l);
2026 int this_label = (int)
prob->
y[i];
2030 if(this_label ==
label[j])
2042 label = (
int *)realloc(
label,max_nr_class*
sizeof(
int));
2043 count = (
int *)realloc(count,max_nr_class*
sizeof(
int));
2057 perm[
start[data_label[i]]] = i;
2058 ++
start[data_label[i]];
2105 for(i=0;i<
prob->
l;i++)
2106 if(fabs(
f.alpha[i]) > 0) ++
nSV;
2111 for(i=0;i<
prob->
l;i++)
2112 if(fabs(
f.alpha[i]) > 0)
2134 info(
"WARNING: training data in only one class. See README for details.\n");
2145 weighted_C[i] =
param->
C;
2146 for(i=0;i<param->nr_weight;i++)
2153 fprintf(stderr,
"WARNING: class label %d specified in weight is not found\n",
param->
weight_label[i]);
2160 bool *nonzero =
Malloc(
bool,
l);
2178 int ci = count[i], cj = count[j];
2181 sub_prob.
y =
Malloc(
double,sub_prob.
l);
2185 sub_prob.
x[k] =
x[si+k];
2190 sub_prob.
x[ci+k] =
x[sj+k];
2191 sub_prob.
y[ci+k] = -1;
2199 if(!nonzero[si+k] && fabs(
f[p].alpha[k]) > 0)
2200 nonzero[si+k] =
true;
2202 if(!nonzero[sj+k] && fabs(
f[p].alpha[ci+k]) > 0)
2203 nonzero[sj+k] =
true;
2243 for(
int j=0;j<count[i];j++)
2244 if(nonzero[
start[i]+j])
2253 info(
"Total nSV = %d\n",total_sv);
2259 if(nonzero[i])
model->
SV[p++] =
x[i];
2264 nz_start[i] = nz_start[i-1]+nz_count[i-1];
2283 int q = nz_start[i];
2339 for(i=0;i<count[
c];i++)
2341 int j = i+rand()%(count[
c]-i);
2352 fold_start[i] = fold_start[i-1]+fold_count[i-1];
2358 for(
int j=begin;j<end;j++)
2360 perm[fold_start[i]] =
index[j];
2366 fold_start[i] = fold_start[i-1]+fold_count[i-1];
2375 for(i=0;i<
l;i++) perm[i]=i;
2378 int j = i+rand()%(
l-i);
2379 swap(perm[i],perm[j]);
2387 int begin = fold_start[i];
2388 int end = fold_start[i+1];
2392 subprob.
l =
l-(end-begin);
2394 subprob.
y =
Malloc(
double,subprob.
l);
2397 for(j=0;j<begin;j++)
2399 subprob.
x[k] =
prob->
x[perm[j]];
2400 subprob.
y[k] =
prob->
y[perm[j]];
2405 subprob.
x[k] =
prob->
x[perm[j]];
2406 subprob.
y[k] =
prob->
y[perm[j]];
2414 for(j=begin;j<end;j++)
2416 free(prob_estimates);
2419 for(j=begin;j<end;j++)
2454 fprintf(stderr,
"Model doesn't contain information for SVR probability inference\n");
2474 return (sum>0)?1:-1;
2483 double *kvalue =
Malloc(
double,
l);
2510 sum += coef1[si+k] * kvalue[si+k];
2512 sum += coef2[sj+k] * kvalue[sj+k];
2514 dec_values[p] = sum;
2516 if(dec_values[p] > 0)
2523 int vote_max_idx = 0;
2525 if(vote[i] > vote[vote_max_idx])
2542 dec_values =
Malloc(
double, 1);
2561 double min_prob=1e-7;
2570 pairwise_prob[j][i]=1-pairwise_prob[i][j];
2575 int prob_max_idx = 0;
2577 if(prob_estimates[i] > prob_estimates[prob_max_idx])
2580 free(pairwise_prob[i]);
2582 free(pairwise_prob);
2591 "c_svc",
"nu_svc",
"one_class",
"epsilon_svr",
"nu_svr",NULL
2596 "linear",
"polynomial",
"rbf",
"sigmoid",
"precomputed",NULL
2601 FILE *fp = fopen(model_file_name,
"w");
2602 if(fp==NULL)
return -1;
2604 char *old_locale = strdup(setlocale(LC_ALL, NULL));
2605 setlocale(LC_ALL,
"C");
2623 fprintf(fp,
"nr_class %d\n",
nr_class);
2624 fprintf(fp,
"total_sv %d\n",
l);
2635 fprintf(fp,
"label");
2643 fprintf(fp,
"probA");
2650 fprintf(fp,
"probB");
2658 fprintf(fp,
"nr_sv");
2664 fprintf(fp,
"SV\n");
2668 for(
int i=0;i<
l;i++)
2671 fprintf(fp,
"%.16g ",
sv_coef[j][i]);
2676 fprintf(fp,
"0:%d ",(
int)(p->
value));
2678 while(p->
index != -1)
2686 setlocale(LC_ALL, old_locale);
2689 if (ferror(fp) != 0 || fclose(fp) != 0)
return -1;
2703 while(strrchr(
line,
'\n') == NULL)
2707 len = (int) strlen(
line);
2716 FILE *fp = fopen(model_file_name,
"rb");
2717 if(fp==NULL)
return NULL;
2719 char *old_locale = strdup(setlocale(LC_ALL, NULL));
2720 setlocale(LC_ALL,
"C");
2735 fscanf(fp,
"%80s",
cmd);
2737 if(strcmp(
cmd,
"svm_type")==0)
2739 fscanf(fp,
"%80s",
cmd);
2751 fprintf(stderr,
"unknown svm type.\n");
2753 setlocale(LC_ALL, old_locale);
2762 else if(strcmp(
cmd,
"kernel_type")==0)
2764 fscanf(fp,
"%80s",
cmd);
2776 fprintf(stderr,
"unknown kernel function.\n");
2778 setlocale(LC_ALL, old_locale);
2787 else if(strcmp(
cmd,
"degree")==0)
2789 else if(strcmp(
cmd,
"gamma")==0)
2791 else if(strcmp(
cmd,
"coef0")==0)
2793 else if(strcmp(
cmd,
"nr_class")==0)
2795 else if(strcmp(
cmd,
"total_sv")==0)
2796 fscanf(fp,
"%d",&
model->
l);
2797 else if(strcmp(
cmd,
"rho")==0)
2801 for(
int i=0;i<n;i++)
2804 else if(strcmp(
cmd,
"label")==0)
2808 for(
int i=0;i<n;i++)
2811 else if(strcmp(
cmd,
"probA")==0)
2815 for(
int i=0;i<n;i++)
2818 else if(strcmp(
cmd,
"probB")==0)
2822 for(
int i=0;i<n;i++)
2825 else if(strcmp(
cmd,
"nr_sv")==0)
2829 for(
int i=0;i<n;i++)
2832 else if(strcmp(
cmd,
"SV")==0)
2837 if(
c==EOF ||
c==
'\n')
break;
2843 fprintf(stderr,
"unknown text in model file: [%s]\n",
cmd);
2845 setlocale(LC_ALL, old_locale);
2858 long pos = ftell(fp);
2862 char *p,*endptr,*idx,*val;
2866 p = strtok(
line,
":");
2869 p = strtok(NULL,
":");
2877 fseek(fp,pos,SEEK_SET);
2895 p = strtok(
line,
" \t");
2897 for(
int k=1;k<m;k++)
2899 p = strtok(NULL,
" \t");
2905 idx = strtok(NULL,
":");
2906 val = strtok(NULL,
" \t");
2919 setlocale(LC_ALL, old_locale);
2922 if (ferror(fp) != 0 || fclose(fp) != 0)
2931 if(model_ptr->
free_sv && model_ptr->
l > 0 && model_ptr->
SV != NULL)
2932 free((
void *)(model_ptr->
SV[0]));
2935 for(
int i=0;i<model_ptr->
nr_class-1;i++)
2939 free(model_ptr->
SV);
2940 model_ptr->
SV = NULL;
2945 free(model_ptr->
rho);
2946 model_ptr->
rho = NULL;
2948 free(model_ptr->
label);
2949 model_ptr->
label= NULL;
2951 free(model_ptr->
probA);
2952 model_ptr->
probA = NULL;
2954 free(model_ptr->
probB);
2955 model_ptr->
probB= NULL;
2957 free(model_ptr->
nSV);
2958 model_ptr->
nSV = NULL;
2963 if(model_ptr_ptr != NULL && *model_ptr_ptr != NULL)
2966 free(*model_ptr_ptr);
2967 *model_ptr_ptr = NULL;
2982 if(svm_type !=
C_SVC &&
2987 return "unknown svm type";
2992 if(kernel_type !=
LINEAR &&
2993 kernel_type !=
POLY &&
2994 kernel_type !=
RBF &&
2997 return "unknown kernel type";
3003 return "degree of polynomial kernel < 0";
3008 return "cache_size <= 0";
3013 if(svm_type ==
C_SVC ||
3023 return "nu <= 0 or nu > 1";
3031 return "shrinking != 0 and shrinking != 1";
3035 return "probability != 0 and probability != 1";
3039 return "one-class SVM probability output not supported yet";
3047 int max_nr_class = 16;
3050 int *count =
Malloc(
int,max_nr_class);
3055 int this_label = (int)
prob->
y[i];
3058 if(this_label ==
label[j])
3068 label = (
int *)realloc(
label,max_nr_class*
sizeof(
int));
3069 count = (
int *)realloc(count,max_nr_class*
sizeof(
int));
3087 return "specified nu is infeasible";
3108 if(print_func == NULL)
int svm_check_probability_model(const svm_model *model)
Cache(int l, long int size)
bool is_upper_bound(int i)
void svm_get_labels(const svm_model *model, int *label)
void update_alpha_status(int i)
virtual Qfloat * get_Q(int column, int len) const =0
virtual double calculate_rho()
static void print_string_stdout(const char *s)
static void solve_c_svc(const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, double Cp, double Cn)
static void svm_group_classes(const svm_problem *prob, int *nr_class_ret, int **label_ret, int **start_ret, int **count_ret, int *perm)
static void solve_nu_svc(const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si)
SVR_Q(const svm_problem &prob, const svm_parameter ¶m)
virtual Qfloat * get_Q(int column, int len) const =0
virtual void swap_index(int i, int j) const
static double svm_svr_probability(const svm_problem *prob, const svm_parameter *param)
void svm_set_print_string_function(void(*print_func)(const char *))
int svm_get_nr_class(const svm_model *model)
static void multiclass_probability(int k, double **r, double *p)
static void swap(T &x, T &y)
SVC_Q(const svm_problem &prob, const svm_parameter ¶m, const schar *y_)
bool is_lower_bound(int i)
static double sigmoid_predict(double decision_value, double A, double B)
svm_model * svm_load_model(const char *model_file_name)
void Solve(int l, const QMatrix &Q, const double *p_, const schar *y_, double *alpha_, double Cp, double Cn, double eps, SolutionInfo *si, int shrinking)
static double k_function(const svm_node *x, const svm_node *y, const svm_parameter ¶m)
static void clone(T *&dst, S *src, int n)
static double dot(const svm_node *px, const svm_node *py)
double svm_predict(const svm_model *model, const svm_node *x)
virtual double * get_QD() const =0
void svm_free_and_destroy_model(svm_model **model_ptr_ptr)
static const char * svm_type_table[]
static decision_function svm_train_one(const svm_problem *prob, const svm_parameter *param, double Cp, double Cn)
bool be_shrunk(int i, double Gmax1, double Gmax2)
void svm_cross_validation(const svm_problem *prob, const svm_parameter *param, int nr_fold, double *target)
struct svm_parameter param
const char * svm_check_parameter(const svm_problem *prob, const svm_parameter *param)
svm_model * svm_train(const svm_problem *prob, const svm_parameter *param)
void reconstruct_gradient()
virtual int select_working_set(int &i, int &j)
double svm_predict_values(const svm_model *model, const svm_node *x, double *dec_values)
static void svm_binary_svc_probability(const svm_problem *prob, const svm_parameter *param, double Cp, double Cn, double &probA, double &probB)
int select_working_set(int &i, int &j)
int svm_save_model(const char *model_file_name, const svm_model *model)
static void(* svm_print_string)(const char *)
double kernel_precomputed(int i, int j) const
int svm_get_svm_type(const svm_model *model)
Qfloat * get_Q(int i, int len) const
struct svm_node * x_space
static void sigmoid_train(int l, const double *dec_values, const double *labels, double &A, double &B)
double kernel_rbf(int i, int j) const
void swap_index(int i, int j)
double(Kernel::* kernel_function)(int i, int j) const
void lru_insert(head_t *h)
static void solve_epsilon_svr(const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si)
Kernel(int l, svm_node *const *x, const svm_parameter ¶m)
static void solve_one_class(const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si)
double svm_predict_probability(const svm_model *model, const svm_node *x, double *prob_estimates)
void swap_index(int i, int j)
void swap_index(int i, int j) const
void lru_delete(head_t *h)
Qfloat * get_Q(int i, int len) const
virtual void swap_index(int i, int j) const =0
void svm_free_model_content(svm_model *model_ptr)
double svm_get_svr_probability(const svm_model *model)
void swap_index(int i, int j) const
static char * readline(FILE *input)
static void info(const char *fmt,...)
bool be_shrunk(int i, double Gmax1, double Gmax2, double Gmax3, double Gmax4)
void svm_destroy_param(svm_parameter *param)
double kernel_poly(int i, int j) const
static double powi(double base, int times)
struct svm_parameter param
double kernel_sigmoid(int i, int j) const
void swap_index(int i, int j) const
Qfloat * get_Q(int i, int len) const
static const char * kernel_type_table[]
ONE_CLASS_Q(const svm_problem &prob, const svm_parameter ¶m)
static void solve_nu_svr(const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si)
double kernel_linear(int i, int j) const
virtual double * get_QD() const =0
int get_data(const int index, Qfloat **data, int len)
virtual void do_shrinking()
void Solve(int l, const QMatrix &Q, const double *p, const schar *y, double *alpha, double Cp, double Cn, double eps, SolutionInfo *si, int shrinking)
haf_grasping
Author(s): David Fischinger
autogenerated on Sat Apr 1 2023 02:23:27