huangchuchuan / SVM-LBP-picture-classifier

使用LBP方法提取特征,再使用svm进行分类
GNU General Public License v3.0
40 stars 21 forks source link

y has 0 samples: array([], dtype=float64) #5

Open DukeLau opened 4 years ago

DukeLau commented 4 years ago

您好,我在将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)

sevenandseven commented 4 years ago

i have the same problem,how can i solve it?

xjcccccccc commented 2 years ago

请问兄弟你解决了吗

xjcccccccc commented 2 years ago

您好,我在将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)))

linnnn1 commented 1 year ago

请问您是怎么解决的呀,我这样修改后仍然是这个错误