SVM训练时交叉验证参数最优选择
来源:互联网 发布:mac idea 窗口最大化 编辑:程序博客网 时间:2024/06/05 01:39
{
param.svm_type = C_SVC;
param.kernel_type = RBF;
param.degree = 3;
param.gamma = (double)1/30;
param.coef0 = 0;
param.nu = 0.5;
param.cache_size = 100;
param.C = 4;
param.eps = 1e-3;
param.p = 0.1;
param.shrinking = 1;
param.probability = 1;
param.nr_weight = 0;
param.weight_label = NULL;
param.weight = NULL;
DoCrossValidation();
}
void SVMExample::DoCrossValidation()
{
int gBegin, gEnd, gStep, cBegin, cEnd, cStep;
int nrFold = 5;
gBegin = -15; gEnd = 3; gStep = 1;
cBegin = -5; cEnd = 15; cStep = 1;
double tempG, tempC, bestG, bestC;
double bestAccuracy = 0;
for (int i=gBegin; i<=gEnd; i+=gStep)
{
tempG = pow(2.0, 1.0*i);
param.gamma = tempG;
for (int j=cBegin; j<=cEnd; j+=cStep)
{
double *target = new double[prob.l];
int totalCorrect = 0;
tempC = pow(2.0, 1.0*j);
param.C = tempC;
svm_cross_validation(&prob, ¶m, nrFold, target);
for (int k=0; k<prob.l; k++)
{
if (target[k] == prob.y[k])
{
totalCorrect++;
}
}
if ((totalCorrect*1.0/prob.l) > bestAccuracy)
{
bestC = tempC;
bestG = tempG;
bestAccuracy = totalCorrect*1.0/prob.l;
}
delete []target;
}
}
param.C = bestC;
param.gamma = bestG;
printf("bestC : %lf ", bestC);
printf("bestG : %lf ", bestG);
printf("bestAccuracy : %lf\n", bestAccuracy);
}
- SVM训练时交叉验证参数最优选择
- sklearn学习-SVM例程总结3(网格搜索+交叉验证——寻找最优超参数)
- SVM分类器的实现(包括交叉验证选择参数,Dlib,可视化)
- 交叉验证--模型参数选择
- libsvm 使用python交叉验证 取最优参数 c g
- 超参数的选择与交叉验证
- sklearn中的交叉验证与参数选择
- SVM之交叉验证【转】
- libsvm交叉验证与网格搜索(参数选择)
- 采用交叉验证选择最佳参数C与g
- libsvm交叉验证与网格搜索(参数选择)
- libsvm交叉验证与网格搜索(参数选择)
- libsvm交叉验证与网格搜索(参数选择)
- CS231n课程笔记5.4:超参数的选择&交叉验证
- 神经网络训练之交叉验证
- 【scikit-learn】交叉验证及其用于参数选择、模型选择、特征选择的例子
- 【scikit-learn】交叉验证及其用于参数选择、模型选择、特征选择的例子
- 【scikit-learn】交叉验证及其用于参数选择、模型选择、特征选择的例子
- 淘宝网核心系统Tengine服务器终于正式开源
- NDK-gdb的错误ERROR(不同于上一篇): Could not extract package's data directory...的解决方法
- [读书笔记]软件架构师应该知道的97件事
- jstl——自定义函数步骤
- Scenes Cluster——场景
- SVM训练时交叉验证参数最优选择
- 商务部刘向东:软件服务需坚持五项基本原则
- Android开发必看知识,不看后悔
- firefox插件真心好用
- ME21N增强提示警告消息
- hibernate级联保存问题,出错not-null property references a null or transient value
- 如何将大数据化为实际收益?
- 如何在word中任意页插入页眉页脚
- Ubuntu下的vim