libsvm-2.91中python接口的使用方法
>>> from svmutil import *
y, x = svm_read_problem('D:/libsvm-2.91/heart_scale')
prob = svm_problem(y, x)
param = svm_parameter('-s 3 -c 5 -h 0')
m = svm_train(y, x, '-c 5')
m = svm_train(prob, '-t 2 -c 5')
m = svm_train(prob, param)
CV_ACC = svm_train(y, x, '-v 3')
>>> >>> >>> >>> .*
optimization finished, #iter = 433
nu = 0.340308
obj = -385.016663, rho = 0.669878
nSV = 121, nBSV = 68
Total nSV = 121
>>> .*
optimization finished, #iter = 433
nu = 0.340308
obj = -385.016663, rho = 0.669878
nSV = 121, nBSV = 68
Total nSV = 121
>>> .*
optimization finished, #iter = 1027
nu = 0.526875
obj = -376.014116, rho = 0.600025
nSV = 190, nBSV = 101
>>> *
optimization finished, #iter = 128
nu = 0.497674
obj = -76.458792, rho = 0.488171
nSV = 103, nBSV = 81
Total nSV = 103
*
optimization finished, #iter = 106
nu = 0.407726
obj = -59.526956, rho = 0.055399
nSV = 83, nBSV = 60
Total nSV = 83
*
optimization finished, #iter = 137
nu = 0.454147
obj = -68.211907, rho = 0.123003
nSV = 94, nBSV = 67
Total nSV = 94
Cross Validation Accuracy = 81.8519%
>>>
?
备注:
libsvm的目录在D:\libsvm-2.91
Python的目录在D:\ProgramXP32\Python26