Predict_proba 具有最相关预测的数组
Predict_proba array with the most relevant predictions
我在 Python 中进行多标签分类(使用 sklearn 库),想知道如何从 predict_proba() 函数中为每个预测标签接收前 5 类在数组形式中看起来就像这样:
y_pred=[[1,3,4,5,2],[4,3,2,1,5],[1,2,3,5,4]]
如何做到这一点?
您可能需要重现您拥有的代码。这是基于某些假设的解决方案。
如果可以存储
predict_proba()
作为一个系列使用,
pd.Series(fit.predict_proba(testdata)[0])
你或许可以使用
predict_proba(testdata).nlargest(n=5)
用索引判断前5个概率,自动排序
我在 Python 中进行多标签分类(使用 sklearn 库),想知道如何从 predict_proba() 函数中为每个预测标签接收前 5 类在数组形式中看起来就像这样:
y_pred=[[1,3,4,5,2],[4,3,2,1,5],[1,2,3,5,4]]
如何做到这一点?
您可能需要重现您拥有的代码。这是基于某些假设的解决方案。
如果可以存储
predict_proba()
作为一个系列使用,
pd.Series(fit.predict_proba(testdata)[0])
你或许可以使用
predict_proba(testdata).nlargest(n=5)
用索引判断前5个概率,自动排序