本文整理了Java中libsvm.svm.info()
方法的一些代码示例,展示了svm.info()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。svm.info()
方法的具体详情如下:
包路径:libsvm.svm
类名称:svm
方法名:info
暂无
代码示例来源:origin: tw.edu.ntu.csie/libsvm
svm.info("Exceeds max_iter in multiclass_prob\n");
代码示例来源:origin: tw.edu.ntu.csie/libsvm
private static double svm_svr_probability(svm_problem prob, svm_parameter param)
{
int i;
int nr_fold = 5;
double[] ymv = new double[prob.l];
double mae = 0;
svm_parameter newparam = (svm_parameter)param.clone();
newparam.probability = 0;
svm_cross_validation(prob,newparam,nr_fold,ymv);
for(i=0;i<prob.l;i++)
{
ymv[i]=prob.y[i]-ymv[i];
mae += Math.abs(ymv[i]);
}
mae /= prob.l;
double std=Math.sqrt(2*mae*mae);
int count=0;
mae=0;
for(i=0;i<prob.l;i++)
if (Math.abs(ymv[i]) > 5*std)
count=count+1;
else
mae+=Math.abs(ymv[i]);
mae /= (prob.l-count);
svm.info("Prob. model for test data: target value = predicted value + z,\nz: Laplace distribution e^(-|z|/sigma)/(2sigma),sigma="+mae+"\n");
return mae;
}
代码示例来源:origin: jzy3d/jzy3d-api
private static double svm_svr_probability(svm_problem prob, svm_parameter param)
{
int i;
int nr_fold = 5;
double[] ymv = new double[prob.l];
double mae = 0;
svm_parameter newparam = (svm_parameter)param.clone();
newparam.probability = 0;
svm_cross_validation(prob,newparam,nr_fold,ymv);
for(i=0;i<prob.l;i++)
{
ymv[i]=prob.y[i]-ymv[i];
mae += Math.abs(ymv[i]);
}
mae /= prob.l;
double std=Math.sqrt(2*mae*mae);
int count=0;
mae=0;
for(i=0;i<prob.l;i++)
if (Math.abs(ymv[i]) > 5*std)
count=count+1;
else
mae+=Math.abs(ymv[i]);
mae /= (prob.l-count);
svm.info("Prob. model for test data: target value = predicted value + z,\nz: Laplace distribution e^(-|z|/sigma)/(2sigma),sigma="+mae+"\n");
return mae;
}
代码示例来源:origin: com.facebook.thirdparty/libsvm
private static double svm_svr_probability(svm_problem prob, svm_parameter param)
{
int i;
int nr_fold = 5;
double[] ymv = new double[prob.l];
double mae = 0;
svm_parameter newparam = (svm_parameter)param.clone();
newparam.probability = 0;
svm_cross_validation(prob,newparam,nr_fold,ymv);
for(i=0;i<prob.l;i++)
{
ymv[i]=prob.y[i]-ymv[i];
mae += Math.abs(ymv[i]);
}
mae /= prob.l;
double std=Math.sqrt(2*mae*mae);
int count=0;
mae=0;
for(i=0;i<prob.l;i++)
if (Math.abs(ymv[i]) > 5*std)
count=count+1;
else
mae+=Math.abs(ymv[i]);
mae /= (prob.l-count);
svm.info("Prob. model for test data: target value = predicted value + z,\nz: Laplace distribution e^(-|z|/sigma)/(2sigma),sigma="+mae+"\n");
return mae;
}
代码示例来源:origin: jzy3d/jzy3d-api
private static void solve_nu_svr(svm_problem prob, svm_parameter param,
double[] alpha, Solver.SolutionInfo si)
{
int l = prob.l;
double C = param.C;
double[] alpha2 = new double[2*l];
double[] linear_term = new double[2*l];
byte[] y = new byte[2*l];
int i;
double sum = C * param.nu * l / 2;
for(i=0;i<l;i++)
{
alpha2[i] = alpha2[i+l] = Math.min(sum,C);
sum -= alpha2[i];
linear_term[i] = - prob.y[i];
y[i] = 1;
linear_term[i+l] = prob.y[i];
y[i+l] = -1;
}
Solver_NU s = new Solver_NU();
s.Solve(2*l, new SVR_Q(prob,param), linear_term, y,
alpha2, C, C, param.eps, si, param.shrinking);
svm.info("epsilon = "+(-si.r)+"\n");
for(i=0;i<l;i++)
alpha[i] = alpha2[i] - alpha2[i+l];
}
代码示例来源:origin: jzy3d/jzy3d-api
double r = si.r;
svm.info("C = "+1/r+"\n");
代码示例来源:origin: com.facebook.thirdparty/libsvm
private static void solve_nu_svr(svm_problem prob, svm_parameter param,
double[] alpha, Solver.SolutionInfo si)
{
int l = prob.l;
double C = param.C;
double[] alpha2 = new double[2*l];
double[] linear_term = new double[2*l];
byte[] y = new byte[2*l];
int i;
double sum = C * param.nu * l / 2;
for(i=0;i<l;i++)
{
alpha2[i] = alpha2[i+l] = Math.min(sum,C);
sum -= alpha2[i];
linear_term[i] = - prob.y[i];
y[i] = 1;
linear_term[i+l] = prob.y[i];
y[i+l] = -1;
}
Solver_NU s = new Solver_NU();
s.Solve(2*l, new SVR_Q(prob,param), linear_term, y,
alpha2, C, C, param.eps, si, param.shrinking);
svm.info("epsilon = "+(-si.r)+"\n");
for(i=0;i<l;i++)
alpha[i] = alpha2[i] - alpha2[i+l];
}
代码示例来源:origin: com.facebook.thirdparty/libsvm
private static void solve_epsilon_svr(svm_problem prob, svm_parameter param,
double[] alpha, Solver.SolutionInfo si)
{
int l = prob.l;
double[] alpha2 = new double[2*l];
double[] linear_term = new double[2*l];
byte[] y = new byte[2*l];
int i;
for(i=0;i<l;i++)
{
alpha2[i] = 0;
linear_term[i] = param.p - prob.y[i];
y[i] = 1;
alpha2[i+l] = 0;
linear_term[i+l] = param.p + prob.y[i];
y[i+l] = -1;
}
Solver s = new Solver();
s.Solve(2*l, new SVR_Q(prob,param), linear_term, y,
alpha2, param.C, param.C, param.eps, si, param.shrinking);
double sum_alpha = 0;
for(i=0;i<l;i++)
{
alpha[i] = alpha2[i] - alpha2[i+l];
sum_alpha += Math.abs(alpha[i]);
}
svm.info("nu = "+sum_alpha/(param.C*l)+"\n");
}
代码示例来源:origin: com.facebook.thirdparty/libsvm
double r = si.r;
svm.info("C = "+1/r+"\n");
代码示例来源:origin: tw.edu.ntu.csie/libsvm
private static void solve_nu_svr(svm_problem prob, svm_parameter param,
double[] alpha, Solver.SolutionInfo si)
{
int l = prob.l;
double C = param.C;
double[] alpha2 = new double[2*l];
double[] linear_term = new double[2*l];
byte[] y = new byte[2*l];
int i;
double sum = C * param.nu * l / 2;
for(i=0;i<l;i++)
{
alpha2[i] = alpha2[i+l] = Math.min(sum,C);
sum -= alpha2[i];
linear_term[i] = - prob.y[i];
y[i] = 1;
linear_term[i+l] = prob.y[i];
y[i+l] = -1;
}
Solver_NU s = new Solver_NU();
s.Solve(2*l, new SVR_Q(prob,param), linear_term, y,
alpha2, C, C, param.eps, si, param.shrinking);
svm.info("epsilon = "+(-si.r)+"\n");
for(i=0;i<l;i++)
alpha[i] = alpha2[i] - alpha2[i+l];
}
代码示例来源:origin: tw.edu.ntu.csie/libsvm
private static void solve_epsilon_svr(svm_problem prob, svm_parameter param,
double[] alpha, Solver.SolutionInfo si)
{
int l = prob.l;
double[] alpha2 = new double[2*l];
double[] linear_term = new double[2*l];
byte[] y = new byte[2*l];
int i;
for(i=0;i<l;i++)
{
alpha2[i] = 0;
linear_term[i] = param.p - prob.y[i];
y[i] = 1;
alpha2[i+l] = 0;
linear_term[i+l] = param.p + prob.y[i];
y[i+l] = -1;
}
Solver s = new Solver();
s.Solve(2*l, new SVR_Q(prob,param), linear_term, y,
alpha2, param.C, param.C, param.eps, si, param.shrinking);
double sum_alpha = 0;
for(i=0;i<l;i++)
{
alpha[i] = alpha2[i] - alpha2[i+l];
sum_alpha += Math.abs(alpha[i]);
}
svm.info("nu = "+sum_alpha/(param.C*l)+"\n");
}
代码示例来源:origin: tw.edu.ntu.csie/libsvm
double r = si.r;
svm.info("C = "+1/r+"\n");
代码示例来源:origin: jzy3d/jzy3d-api
private static void solve_epsilon_svr(svm_problem prob, svm_parameter param,
double[] alpha, Solver.SolutionInfo si)
{
int l = prob.l;
double[] alpha2 = new double[2*l];
double[] linear_term = new double[2*l];
byte[] y = new byte[2*l];
int i;
for(i=0;i<l;i++)
{
alpha2[i] = 0;
linear_term[i] = param.p - prob.y[i];
y[i] = 1;
alpha2[i+l] = 0;
linear_term[i+l] = param.p + prob.y[i];
y[i+l] = -1;
}
Solver s = new Solver();
s.Solve(2*l, new SVR_Q(prob,param), linear_term, y,
alpha2, param.C, param.C, param.eps, si, param.shrinking);
double sum_alpha = 0;
for(i=0;i<l;i++)
{
alpha[i] = alpha2[i] - alpha2[i+l];
sum_alpha += Math.abs(alpha[i]);
}
svm.info("nu = "+sum_alpha/(param.C*l)+"\n");
}
代码示例来源:origin: tw.edu.ntu.csie/libsvm
private static void solve_c_svc(svm_problem prob, svm_parameter param,
double[] alpha, Solver.SolutionInfo si,
double Cp, double Cn)
{
int l = prob.l;
double[] minus_ones = new double[l];
byte[] y = new byte[l];
int i;
for(i=0;i<l;i++)
{
alpha[i] = 0;
minus_ones[i] = -1;
if(prob.y[i] > 0) y[i] = +1; else y[i] = -1;
}
Solver s = new Solver();
s.Solve(l, new SVC_Q(prob,param,y), minus_ones, y,
alpha, Cp, Cn, param.eps, si, param.shrinking);
double sum_alpha=0;
for(i=0;i<l;i++)
sum_alpha += alpha[i];
if (Cp==Cn)
svm.info("nu = "+sum_alpha/(Cp*prob.l)+"\n");
for(i=0;i<l;i++)
alpha[i] *= y[i];
}
代码示例来源:origin: com.facebook.thirdparty/libsvm
private static void solve_c_svc(svm_problem prob, svm_parameter param,
double[] alpha, Solver.SolutionInfo si,
double Cp, double Cn)
{
int l = prob.l;
double[] minus_ones = new double[l];
byte[] y = new byte[l];
int i;
for(i=0;i<l;i++)
{
alpha[i] = 0;
minus_ones[i] = -1;
if(prob.y[i] > 0) y[i] = +1; else y[i] = -1;
}
Solver s = new Solver();
s.Solve(l, new SVC_Q(prob,param,y), minus_ones, y,
alpha, Cp, Cn, param.eps, si, param.shrinking);
double sum_alpha=0;
for(i=0;i<l;i++)
sum_alpha += alpha[i];
if (Cp==Cn)
svm.info("nu = "+sum_alpha/(Cp*prob.l)+"\n");
for(i=0;i<l;i++)
alpha[i] *= y[i];
}
代码示例来源:origin: jzy3d/jzy3d-api
private static void solve_c_svc(svm_problem prob, svm_parameter param,
double[] alpha, Solver.SolutionInfo si,
double Cp, double Cn)
{
int l = prob.l;
double[] minus_ones = new double[l];
byte[] y = new byte[l];
int i;
for(i=0;i<l;i++)
{
alpha[i] = 0;
minus_ones[i] = -1;
if(prob.y[i] > 0) y[i] = +1; else y[i]=-1;
}
Solver s = new Solver();
s.Solve(l, new SVC_Q(prob,param,y), minus_ones, y,
alpha, Cp, Cn, param.eps, si, param.shrinking);
double sum_alpha=0;
for(i=0;i<l;i++)
sum_alpha += alpha[i];
if (Cp==Cn)
svm.info("nu = "+sum_alpha/(Cp*prob.l)+"\n");
for(i=0;i<l;i++)
alpha[i] *= y[i];
}
代码示例来源:origin: com.facebook.thirdparty/libsvm
svm.info("obj = "+si.obj+", rho = "+si.rho+"\n");
svm.info("nSV = "+nSV+", nBSV = "+nBSV+"\n");
代码示例来源:origin: tw.edu.ntu.csie/libsvm
svm.info("\nWARNING: using -h 0 may be faster\n");
代码示例来源:origin: jzy3d/jzy3d-api
svm.info("\nWarning: using -h 0 may be faster\n");
代码示例来源:origin: com.facebook.thirdparty/libsvm
svm.info("\nWARNING: using -h 0 may be faster\n");
内容来源于网络,如有侵权,请联系作者删除!