문제

I've been trying to do simple binary classification using SimpleCV's SVMClassifier. Here's what I've tried, followed by the error:

svm = SVMClassifier([HueHistogramFeatureExtractor])
svm.train([train_airplanes, train_leaves], ['Airplanes', 'Leaves'])

error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-31-50d09bd20b62> in <module>()
      1 svm = SVMClassifier([HueHistogramFeatureExtractor])
----> 2 svm.train([train_airplanes, train_leaves], ['Airplanes', 'Leaves'])

/usr/local/lib/python2.7/dist-packages/SimpleCV/MachineLearning/SVMClassifier.pyc in train(self, paths, classNames, disp, subset, savedata, verbose)
    229         colNames = []
    230         for extractor in self.mFeatureExtractors:
--> 231             colNames.extend(extractor.getFieldNames())
    232 
    233         if(count <= 0):

TypeError: unbound method getFieldNames() must be called with HueHistogramFeatureExtractor instance as first argument (got nothing instead)

The documentation is pretty sparse, so I'm not sure what I should be doing differently.

도움이 되었습니까?

해결책

I know this answer is probably too late in your case, but maybe it will help others:

You must give the classifiers instances of FeatureExtractors, not classes, so you should have done:

svm = SVMClassifier([HueHistogramFeatureExtractor()])
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top