您当前的位置:matlab资源网文章中心资料 → 文章内容

windows下使用libsvm

作者:swjtu  来源:转载http://www.blog.edu.cn/user5/283105/archives/2008/2098586.shtml  发布时间:2008-4-17 8:36:04

http://www.csie.ntu.edu.tw/~cjlin/下载libsvm-2.84;gridregression.py

在python的主页http://www.python.org上下载python-2.5
gridregression.py中用到了绘图工具gnuplot,需要下载一个gnuplot软件,地址:ftp://ftp.gnuplot.info/pub/gnuplot/(win32版本)
样本数据指定格式:[label] [index1]:[value1] [index2]:[value2] ……
(1)svmscale.exe的用法:
 svmscale.exe [-1 lower] [-u upper] [-y y_lower y_upper] [-s save_filename] [-r restore_filename] filename
(2)svmtrtrain.exe训练模型:
     svmtrain.exe -s 3 -t 2 -c 200  -p 0.0001 -g 0.1 grain_scale>train.txt(最好)
其中,用gridregression.py搜索最优参数的方法如下:

Usage: grid.py [-log2c begin,end,step] [-log2g begin,end,step] [-log2p begin,end,step] [-v fold]
[-svmtrain pathname] [-gnuplot pathname] [-out pathname] [-png pathname]
[additional parameters for svm-train] dataset

eg:
C:\libsvm-2.84\python>C:\Python25\python.exe gridregression.py -svmtrain C:\libsvm-2.84\windows\svmtrain.exe -gnuplot

C:\libsvm-2.84\windows\gnuplot\pgnuplot.exe -log2c 10,1000,10 -log2g 0.01,1.0,0.01 -log2p 0,0.1,0.001 -v 10 -s 3 -t 2

C:\libsvm-2.84\windows\grain_scale>gridregression_feature.parameter

(3)用svmpredict.exe进行预测
 svmpredict.exe Tgrain_scale grain_scale.model T_predict>predicted.txt
其中feature_test.scaled是归一化后的测试特征文件名,feature.scaled.model是训练好的模型,SVM预测的值在feature_test.predicted中。

 
  • 上一篇文章:P-Q潮流计算
  • 下一篇文章:粒子群算法(PSO)源代码
  • 文章评论 (评论内容只代表网友观点,与本站立场无关!)

    用户名: 查看更多评论

    分 值:100分 85分 70分 55分 40分 25分 10分 0分

    内 容:

             (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码

    关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 -