英文:
TypeError: auc() got an unexpected keyword argument 'reorder'
问题
请告诉我为什么会出现这个错误?
def roc_aupr_score(y_true, y_score, average="macro"):
def _binary_roc_aupr_score(y_true, y_score):
precision, recall, pr_thresholds = precision_recall_curve(y_true, y_score)
return auc(recall, precision)
File "DDIMDL.py", line 387, in <module>
main(args)
File "DDIMDL.py", line 367, in main
all_result, each_result = cross_validation(all_matrix, new_label, clf, event_num, seed, CV,
File "DDIMDL.py", line 190, in cross_validation
result_all, result_eve = evaluate(y_pred, y_score, y_true, event_num, set_name)
File "DDIMDL.py", line 214, in evaluate
result_all[1] = roc_aupr_score(y_one_hot, pred_score, average='micro')
File "DDIMDL.py", line 301, in roc_aupr_score
return _average_binary_score(_binary_roc_aupr_score, y_true, y_score, average)
File "DDIMDL.py", line 298, in _average_binary_score
score[c] = binary_metric(y_true_c, y_score_c)
File "DDIMDL.py", line 281, in _binary_roc_aupr_score
return auc(recall, precision)
TypeError: auc() got an unexpected keyword argument 'reorder'
我应该如何更正它?
请告诉我如何解决这个问题。
英文:
Kindly let me know why this error is coming?
def roc_aupr_score(y_true, y_score, average="macro"):
def _binary_roc_aupr_score(y_true, y_score):
precision, recall, pr_thresholds = precision_recall_curve(y_true, y_score)
return auc(recall, precision, reorder=True)
File "DDIMDL.py", line 387, in <module>
main(args)
File "DDIMDL.py", line 367, in main
all_result, each_result = cross_validation(all_matrix, new_label, clf, event_num, seed, CV,
File "DDIMDL.py", line 190, in cross_validation
result_all, result_eve = evaluate(y_pred, y_score, y_true, event_num, set_name)
File "DDIMDL.py", line 214, in evaluate
result_all[1] = roc_aupr_score(y_one_hot, pred_score, average='micro')
File "DDIMDL.py", line 301, in roc_aupr_score
return _average_binary_score(_binary_roc_aupr_score, y_true, y_score, average)
File "DDIMDL.py", line 298, in _average_binary_score
score[c] = binary_metric(y_true_c, y_score_c)
File "DDIMDL.py", line 281, in _binary_roc_aupr_score
return auc(recall, precision, reorder=True)
TypeError: auc() got an unexpected keyword argument 'reorder'
how can i correct it
kindly let me know how can solve the issue.
答案1
得分: 1
如评论中讨论的,reorder
参数已在版本 0.20
中弃用,并在 0.22
中移除。
def roc_aupr_score(y_true, y_score, average="macro"):
def _binary_roc_aupr_score(y_true, y_score):
precision, recall, pr_thresholds = precision_recall_curve(y_true, y_score)
return auc(recall, precision)
应该按预期工作。如果不行,你可以像这样对 `precision` 和 `recall` 进行排序:
```python
precision, recall, pr_thresholds = precision_recall_curve(y_true, y_score)
new_order = np.lexsort([recall, precision])
recall = recall[new_order]
precision = precision[new_order]
print(recall, precision)
return auc(recall, precision)
英文:
As discussed in the comments, reorder
parameter has been deprecated in version 0.20
and removed in 0.22
def roc_aupr_score(y_true, y_score, average="macro"):
def _binary_roc_aupr_score(y_true, y_score):
precision, recall, pr_thresholds = precision_recall_curve(y_true, y_score)
return auc(recall, precision)
Should work as intented. If not, you can sort precision
and recall
like this:
precision, recall, pr_thresholds = precision_recall_curve(y_true, y_score)
new_order = np.lexsort([recall, precision])
recall = recall[new_order]
precision = precision[new_order]
print(recall , precision )
return auc(recall, precision)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论