Open DukeLau opened 4 years ago
i have the same problem,how can i solve it?
请问兄弟你解决了吗
您好,我在将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.labelbinarizer.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)))
请问您是怎么解决的呀,我这样修改后仍然是这个错误
您好,我在将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.labelbinarizer.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)