我一直在尝试使用SimpleCV的SVMClassifier
进行简单的二进制分类。这是我尝试过的,然后是错误:
svm = SVMClassifier([HueHistogramFeatureExtractor])
svm.train([train_airplanes, train_leaves], ['Airplanes', 'Leaves'])
错误:
---------------------------------------------------------------------------
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)
文档很稀疏,所以我不确定我应该做些什么。
答案 0 :(得分:2)
我知道这个答案在你的案子中可能为时已晚,但也许它会对其他人有所帮助:
你必须给出FeatureExtractors的分类器实例,而不是类,所以你应该这样做:
svm = SVMClassifier([HueHistogramFeatureExtractor()])