gpt4 book ai didi

scala - 在 Spark RandomForestClassifier 中预测类别概率

转载 作者:行者123 更新时间:2023-12-01 03:38:58 25 4
gpt4 key购买 nike

我使用 ml.classification.RandomForestClassifier 构建了随机森林模型。我试图从模型中提取预测概率,但我只看到了预测类而不是概率。根据这个issue link ,问题已解决并导致此 github pull requestthis .但是,似乎在 1.5 版中已解决。我正在使用提供 Spark 1.4.1 的 AWS EMR 并且不知道如何获得预测概率。如果有人知道该怎么做,请分享您的想法或解决方案。谢谢!

最佳答案

我已经回答过类似的 question前。

不幸的是,使用 MLLIb,直到版本 1.4.1,您才能获得分类模型的每个实例的概率。

有 JIRA 问题( SPARK-4362SPARK-6885 )关于这个确切的主题,在我现在写答案时正在进行中。尽管如此,该问题似乎自 2014 年 11 月以来就搁置了

There is currently no way to get the posterior probability of a prediction with Naive Baye's model during prediction. This should be made available along with the label.



以下是@sean-owen 在邮件列表中关于朴素贝叶斯分类算法的类似主题的注释:

This was recently discussed on this mailing list. You can't get the probabilities out directly now, but you can hack a bit to get the internal data structures of NaiveBayesModel and compute it from there.



引用: source .

此问题已 已解决 使用 Spark 1.5.0。请引用JIRA issue更多细节。

关于 AWS ,您现在无能为力。如果您可以 fork emr-bootstrap-actions for spark,可能的解决方案是并根据您的需要进行配置,然后您就可以使用引导步骤在 AWS 上安装 Spark。

尽管如此,这似乎有点复杂。

您可能需要考虑一些事情:
  • 更新 spark/config.file安装 spark-1.5。就像是 :
    +3  1.5.0   python  s3://support.elasticmapreduce/spark/install-spark-script.py s3://path.to.your.bucket.spark.installation/spark/1.5.0/spark-1.5.0.tgz
  • 上面的这个文件列表必须是正确构建的 spark,位于您目前拥有的指定 s3 存储桶中。
  • 为了建立你的 Spark ,我建议你在例子中阅读它 section about building-spark-for-emr还有 official documentation .应该是这样的! (希望我没有忘记任何事情)

  • 编辑:Amazon EMR 版本 4.1.0 提供了 Apache Spark (1.5.0) 的升级版本。您可以查看 here更多细节。

    关于scala - 在 Spark RandomForestClassifier 中预测类别概率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32259015/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com