作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 sklearn 中使用随机森林进行二元分类时。我知道我可以使用 clf.predict(X)
来获取预测类。当我使用 clf.predict_proba(X)
时,我得到一个如下所示的数组:
我认为第一列表示预测的概率?我怎样才能得到一个列,该列是类别为 1 的概率?
最佳答案
来自RandomForest.predict_proba
文档:
predict_proba(X)
Predict class probabilities for X.
Returns:
p
: [...] The class probabilities of the input samples. The order of the classes corresponds to that in the attributeclasses_
.
您可以查看 clf.classes_
属性,查看您的类 1
出现的索引,然后按如下方式访问概率:
prob_class_1 = clf.predict_proba(X)[:, i]
其中 i
是 clf.classes_
中类 1
的索引。
关于python - 获取某个类别的一列概率值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46147015/
我是一名优秀的程序员,十分优秀!