libSVM Python界面出错

时间:2012-07-07 05:43:17

标签: python libsvm

我致电

 model = svm_model(svm_problem(prob_y, prob_x), svm_param)

但我收到错误:

Traceback (most recent call last):
  File "./multiprob.py", line 267, in <module>
    main()
  File "./multiprob.py", line 226, in main
    train_x, train_y, test_x, test_y, param, outfile)
  File "./multiprob.py", line 89, in testing
    model[i,j]=base_train(cls_x[i], cls_x[j], param)
  File "/data/svm/svmprob-1.2/svmPlatt.py", line 15, in SvmPlattTrain
    model = svm_model(svm_problem(prob_y, prob_x), svm_param)
TypeError: __init__() takes exactly 1 argument (3 given)

我查看/usr/lib64/python2.6/site-packages/libsvm/svm.py中的代码

class svm_model(Structure):
>---_names = ['param', 'nr_class', 'l', 'SV', 'sv_coef', 'rho',
>--->--->---'probA', 'probB', 'label', 'nSV', 'free_sv']
>---_types = [svm_parameter, c_int, c_int, POINTER(POINTER(svm_node)),
>--->--->---POINTER(POINTER(c_double)), POINTER(c_double),
>--->--->---POINTER(c_double), POINTER(c_double), POINTER(c_int),
>--->--->---POINTER(c_int), c_int]
>---_fields_ = genFields(_names, _types)

>---def __init__(self):
>--->---self.__createfrom__ = 'python'

init _ 只取一个参数......如何解决?

1 个答案:

答案 0 :(得分:0)

这是针对libSVM的版本错误。 libSVM 3.x更改了libSVM 2.8.9中使用的模型。