gpt4 book ai didi

scala - 如何在随机森林中使用 Spark 特征重要性?

转载 作者:行者123 更新时间:2023-12-04 08:42:21 25 4
gpt4 key购买 nike

documentationRandom Forests不包括特征重要性。但是,它列在 Jira 上已解决并在 source code 中. HERE还说“此 API 与原始 MLlib 集成 API 之间的主要区别是:

  • 支持数据帧和机器学习管道
  • 分类与回归的分离
  • 使用 DataFrame 元数据区分连续和分类
    功能
  • 更多随机森林功能:特征估计
    重要性
    ,以及每个类别的预测概率
    (又名类条件概率)用于分类。”

  • 但是,我无法找出可以调用此新功能的语法。
    scala> model
    res13: org.apache.spark.mllib.tree.model.RandomForestModel =
    TreeEnsembleModel classifier with 10 trees

    scala> model.featureImportances
    <console>:60: error: value featureImportances is not a member of org.apache.spark.mllib.tree.model.RandomForestModel
    model.featureImportances

    最佳答案

    您必须使用新的随机森林。检查您的进口。
    老人:

    import org.apache.spark.mllib.tree.RandomForest
    import org.apache.spark.mllib.tree.model.RandomForestModel

    新的随机森林使用:
    import org.apache.spark.ml.classification.RandomForestClassificationModel
    import org.apache.spark.ml.classification.RandomForestClassifier

    This S.O. answer provides code for extracting the importances.

    This S.O. answer explains the sparse vector that is returned.

    关于scala - 如何在随机森林中使用 Spark 特征重要性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34622194/

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