我是 sklearn 的新手,一般来说也是 python 的新手。你能帮我弄清楚这个脚本是否会导致一些解决方案吗?基本上我在图像集上使用色调提取器:加载 iset 进行训练、提取特征、定义分类器然后分类。
#load beach for training
iset = ImageSet('/Users/Arenzky/Desktop/img_dirs/supervised/beach/') #load Image database
hue = HueHistogramFeatureExtractor() # define extractor
edge = EdgeHistogramFeatureExtractor()
x = []
y = []
for b in iset:
...: x.append(hue.extract(b))
hset = ImageSet('/dir/.../h01/')
hue = HueHistogramFeatureExtractor() # define extractor
edge = EdgeHistogramFeatureExtractor()
for h01 in hset:
...: y.append(hue.extract(h01))
dataset = np.array(x)
targets = np.array(y)
print 'Training Machine Learning'
clf = LinearSVC()
clf = clf.fit(x, y)
clf2 = LogisticRegression().fit(x, y)
#predict
...加载 clf 后,我得到:
ValueError:
X and Y have incompatible shapes. X has 20 samples, but Y has 286.