> 您好,我在将map改为list求长度后,好像是标签没有添加进去,请问是什么原因呢? File "d:/vscode/SVM-LBP-picture-classifier-master/main.py", line 124, in s = main() File "d:/vscode/SVM-LBP-picture-classifier-master/main.py", line 114, in main score = OneVsRestClassifier(svr_rbf, n_jobs=-1).fit(train_hist_array, train_label_array).score(test_hist_array, File "C:\Users\nangu\Anaconda3\lib\site-packages\sklearn\multiclass.py", line 204, in fit Y = self.label_binarizer_.fit_transform(y) File "C:\Users\nangu\Anaconda3\lib\site-packages\sklearn\preprocessing\label.py", line 307, in fit_transform return self.fit(y).transform(y) File "C:\Users\nangu\Anaconda3\lib\site-packages\sklearn\preprocessing\label.py", line 281, in fit raise ValueError('y has 0 samples: %r' % y) ValueError: y has 0 samples: array([], dtype=float64) #7
> 您好,我在将map改为list求长度后,好像是标签没有添加进去,请问是什么原因呢? File "d:/vscode/SVM-LBP-picture-classifier-master/main.py", line 124, in s = main() File "d:/vscode/SVM-LBP-picture-classifier-master/main.py", line 114, in main score = OneVsRestClassifier(svr_rbf, n_jobs=-1).fit(train_hist_array, train_label_array).score(test_hist_array, File "C:\Users\nangu\Anaconda3\lib\site-packages\sklearn\multiclass.py", line 204, in fit Y = self.label_binarizer_.fit_transform(y) File "C:\Users\nangu\Anaconda3\lib\site-packages\sklearn\preprocessing\label.py", line 307, in fit_transform return self.fit(y).transform(y) File "C:\Users\nangu\Anaconda3\lib\site-packages\sklearn\preprocessing\label.py", line 281, in fit raise ValueError('y has 0 samples: %r' % y) ValueError: y has 0 samples: array([], dtype=float64)
我已经解决了,debug过程中发现pos_file_path_list和neg_file_path_list是空,只要将map变为list就行 pos_file_path_list = list(map(lambda x: os.path.join(RESIZE_POS_IMAGE_DIR, x), os.listdir(RESIZE_POS_IMAGE_DIR))) neg_file_path_list = list(map(lambda x: os.path.join(RESIZE_NEG_IMAGE_DIR, x), os.listdir(RESIZE_NEG_IMAGE_DIR)))
Originally posted by @xjcccccccc in https://github.com/huangchuchuan/SVM-LBP-picture-classifier/issues/5#issuecomment-1231092419