如何更改 SimpleCV 的 SVMClassifier 中的属性

How to Change Properties in SimpleCV's SVMClassifier

在文档中:SVMClassifier Documentationclass SimpleCV.MachineLearning.SVMClassifier.SVMClassifier(featureExtractors, properties=None)

Code of class SVMClassifier

    mSVMProperties = {
    'KernelType':'RBF', #default is a RBF Kernel
    'SVMType':'NU',     #default is C 
    'nu':None,          # NU for SVM NU
    'c':None,           #C for SVM C - the slack variable
    'degree':None,      #degree for poly kernels - defaults to 3
    'coef':None,        #coef for Poly/Sigmoid defaults to 0
    'gamma':None,       #kernel param for poly/rbf/sigma - default is 1/#samples       
}

...

        self.mKernelType = {
        'RBF':orange.SVMLearner.RBF, #Radial basis kernel
        'Linear':orange.SVMLearner.Linear, #Linear basis kernel
        'Poly':orange.SVMLearner.Polynomial, #Polynomial kernel
        'Sigmoid':orange.SVMLearner.Sigmoid #Sigmoid Kernel
    }

...

    self.mSVMType = {
        'NU':orange.SVMLearner.Nu_SVC,
        'C':orange.SVMLearner.C_SVC
    }

如何设置KernelType? ex:to 'Linear',我试过这个代码

classifier = SVMClassifier(feature_extractors,{'KernelType':'Linear'})

出现错误

 ERROR:
    Traceback (most recent call last):
      File "ntitrasi.py", line 56, in <module>
        classifier = SVMClassifier(feature_extractors,{'KernelType':'Linear'})
      File "C:\Python27\lib\site-packages\simplecv-1.3-py2.7.egg\SimpleCV\MachineLea
    rning\SVMClassifier.py", line 70, in __init__
        self._parameterizeKernel()
      File "C:\Python27\lib\site-packages\simplecv-1.3-py2.7.egg\SimpleCV\MachineLea
    rning\SVMClassifier.py", line 90, in _parameterizeKernel
        self.mSVMPrototype.svm_type = self.mSVMType[self.mSVMProperties["SVMType"]]
    KeyError: 'SVMType'

我也试过这个

classifier = SVMClassifier(feature_extractors,{'KernelType':'Linear','SVMType':'C'})

还有一个错误:

ERROR:
Traceback (most recent call last):
  File "ntitrasi.py", line 56, in <module>
    classifier = SVMClassifier(feature_extractors,{'KernelType':'Linear','SVMTyp
e':'C'})
  File "C:\Python27\lib\site-packages\simplecv-1.3-py2.7.egg\SimpleCV\MachineLea
rning\SVMClassifier.py", line 70, in __init__
    self._parameterizeKernel()
  File "C:\Python27\lib\site-packages\simplecv-1.3-py2.7.egg\SimpleCV\MachineLea
rning\SVMClassifier.py", line 92, in _parameterizeKernel
    if(self.mSVMProperties["nu"] is not None):
KeyError: 'nu'

您是否尝试将 nu 包含在参数列表中?:

classifier = SVMClassifier(feature_extractors,{'KernelType':'Linear','SVMType':'C','nu':None})?