When I run 'run_bert.py', I have a error below. How can I fix it
xueyongfu opened this issue · comments
Traceback (most recent call last):
File "run_bert.py", line 218, in
main()
File "run_bert.py", line 211, in main
run_train(args)
File "run_bert.py", line 119, in run_train
trainer.train(train_data=train_dataloader, valid_data=valid_dataloader)
File "/home//Bert-Multi-Label-Text-Classification/pybert/train/trainer.py", line 154, in train
valid_log = self.valid_epoch(valid_data)
File "/home/Bert-Multi-Label-Text-Classification/pybert/train/trainer.py", line 81, in valid_epoch
value = metric.value()
File "/home/Bert-Multi-Label-Text-Classification/pybert/train/metrics.py", line 300, in value
auc = roc_auc_score(y_score=self.y_prob[:, i], y_true=self.y_true[:, i])
File "/home/xyf/anaconda3/envs/py36_torch1.2/lib/python3.6/site-packages/sklearn/metrics/ranking.py", line 355, in roc_auc_score
sample_weight=sample_weight)
File "/home/xyf/anaconda3/envs/py36_torch1.2/lib/python3.6/site-packages/sklearn/metrics/base.py", line 76, in _average_binary_score
return binary_metric(y_true, y_score, sample_weight=sample_weight)
File "/home/xyf/anaconda3/envs/py36_torch1.2/lib/python3.6/site-packages/sklearn/metrics/ranking.py", line 323, in _binary_roc_auc_score
raise ValueError("Only one class present in y_true. ROC AUC score "
ValueError: Only one class present in y_true. ROC AUC score is not defined in that case.
Hi
I met the same error. I think it is beacuse of your train data is Unbalanced data. Some categories have only one instance.You can see roc_auc_score function.
And Chinese?
Hi
I met the same error. I think it is beacuse of your train data is Unbalanced data. Some categories have only one instance.You can see roc_auc_score function.And Chinese?
yes,I solved it