我正在尝试使用 sklearn gridsearchcv 进行超参数调整。我希望使用度量“precision_recall_curve 下的区域”。
gridsearchcv 类似于
>>> parameters = {'kernel':('linear', 'rbf'), 'C':[1, 10]}
>>> svc = svm.SVC()
>>> clf = GridSearchCV(svc, parameters, scoring='accuracy')
>>> clf.fit(iris.data, iris.target)
所以基本上我想要的是将字符串“accuracy”更改为 precision_recall_curve 下的区域。我应该如何定制它?
最佳答案
精确率-召回率曲线下的面积可以通过 average_precision_score
来估计。来自其documentation :
AP [Average Precision] summarizes a precision-recall curve as the weighted mean of precisions achieved at each threshold, with the increase in recall from the previous threshold used as the weight.
实际上,这是精确召回曲线下面积的近似值,并在 scikit-learn
中实现。有一个很棒的博客可用here总结了其背后的概念,并链接到 Wikipedia article其中指出:
[Average precision] is the area under the precision-recall curve.
可以通过指定 average_cision
作为评分方法来使用 average_ precision_score
:
clf = GridSearchCV(svc, parameters, scoring='average_precision')
但是,请保持这一点重要note关于average_ precision_score
请记住:
This implementation is not interpolated and is different from computing the area under the precision-recall curve with the trapezoidal rule, which uses linear interpolation and can be too optimistic.
关于scikit-learn - 如何在gridsearchcv中使用精确召回曲线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68567722/