是否可以从决策树分类器predivit_proba()获得dict {class {class:proba}?
我的模型有超过1K的类,该方法返回带有概率的数组,其中大多数为0。我想获得具有其概率的前3个预测。我该如何实施? 我希望能得到这样的东西:
[{class: proba}, {class: proba}, {class: proba}]
My model have more than 1k classes, and the method returns an array with probabilities, most of which are 0. I want to get top 3 predictions with their probabilities. How can i implement this?
I expect to get something like this:
[{class: proba}, {class: proba}, {class: proba}]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设它是一个示例:
对于较大的测试集,它将成长为类似:
argpartition
就像argsort
,但只能整理出该符号中最大值的3个索引,为您节省一些复杂性。或者,如果您不介意仅为此导入火炬,则有一个不错的
.topk()
张量的方法。Assuming it's one sample:
For a larger test set it'll grow into something like:
argpartition
is likeargsort
but would only sort out 3 indices with largest values in this notation, saving you some complexity.Or, if you don't mind importing torch just for this, it's got a nice
.topk()
method for tensors.