- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有没有办法可视化/绘制使用 pyspark 中的 mllib 或 ml 库创建的决策树。还有如何获取叶节点中的记录数等信息。谢谢
最佳答案
首先,您需要使用 model.toDebugString 来获取与随机森林模型类似的输出:
"RandomForestClassificationModel (uid=rfc_6c4ceb92ba78) with 20 trees
Tree 0 (weight 1.0):
If (feature 0 <= 3="" 10="" 1.0)="" if="" (feature="" <="0.0)" predict:="" 0.0="" else=""> 6.0)
Predict: 0.0
Else (feature 10 > 0.0)
If (feature 12 <= 12="" 63.0)="" predict:="" 0.0="" else="" (feature=""> 63.0)
Predict: 0.0
Else (feature 0 > 1.0)
If (feature 13 <= 3="" 1.0)="" if="" (feature="" <="3.0)" predict:="" 0.0="" else=""> 3.0)
Predict: 1.0
Else (feature 13 > 1.0)
If (feature 7 <= 7="" 1.0)="" predict:="" 0.0="" else="" (feature=""> 1.0)
Predict: 0.0
Tree 1 (weight 1.0):
If (feature 2 <= 11="" 15="" 1.0)="" if="" (feature="" <="0.0)" predict:="" 0.0="" else=""> 0.0)
Predict: 1.0
Else (feature 15 > 0.0)
If (feature 11 <= 11="" 0.0)="" predict:="" 0.0="" else="" (feature=""> 0.0)
Predict: 1.0
Else (feature 2 > 1.0)
If (feature 12 <= 5="" 31.0)="" if="" (feature="" <="0.0)" predict:="" 0.0="" else=""> 0.0)
Predict: 0.0
Else (feature 12 > 31.0)
If (feature 3 <= 3="" 4.0)="" predict:="" 0.0="" else="" (feature=""> 4.0)
Predict: 0.0
Tree 2 (weight 1.0):
If (feature 8 <= 4="" 6="" 1.0)="" if="" (feature="" <="2.0)" predict:="" 0.0="" else=""> 10875.0)
Predict: 1.0
Else (feature 6 > 2.0)
If (feature 1 <= 1="" 36.0)="" predict:="" 0.0="" else="" (feature=""> 36.0)
Predict: 1.0
Else (feature 8 > 1.0)
If (feature 5 <= 4="" 0.0)="" if="" (feature="" <="4113.0)" predict:="" 0.0="" else=""> 4113.0)
Predict: 1.0
Else (feature 5 > 0.0)
If (feature 11 <= 11="" 2.0)="" predict:="" 0.0="" else="" (feature=""> 2.0)
Predict: 0.0
Tree 3 ...
将其保存在某个 .txt 文件下,然后使用: https://github.com/tristaneljed/Decision-Tree-Visualization-Spark
关于pyspark - 如何在 pyspark 中可视化决策树模型/对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45717085/
是否有显示测试用例数量以提供决策/条件覆盖率的工具? 例如: if(x>0) if(x0) 3 个案例足以覆盖决策/条件。 if(x>0) if(x0) 4 个案例足以覆盖决策/条件。 这是真的吗?
我正在尝试找到一种优雅的方式来实现易于维护的决策算法,因为决策的条件可能经常变化。 我将尝试更具体地举一个例子: 假设我正在尝试管理一家餐厅厨房的 cooking 厨师团队。 每个厨师都知道如何 co
我需要一个 Android Activity ,它应该显示一个字段,如带有图像的标题和其下方的几个动态生成的项目(我认为是 1 到 100)。如果我不想让 headsection 滚动,我会使用 Li
我正在编写函数以从值列表中提供最大值(value)。我的问题是如果所有值都相同怎么办?例如, 30,29,34,45 简单。最大值为 45。现在, 20,20,20,20 这里的最大值是20吗?或者没
我需要知道哪个检索事件日志的速度更快,但我在比较中找不到:假设需要查找的所有列都有btree索引,需要查找的json对象中的所有键都有GIN索引。 case 1: ActivityID (in
我需要在我的 iPhone 应用程序中显示一个表格: neither the number of cells nor the contents are known at compile time, b
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
这是针对在 MinGW/Windows 上使用 SDL 的小型游戏项目。 我正在研究一个物理引擎,我的想法是拥有一个Physics::Object,所有物理对象都应该派生自它,并且它会在全局 Phys
我有一个小的 LINQ 查询来填充下拉控件(WinForms Telerik 应用程序),其中的数据行显示两个值(ITNBR 和描述): var query = from i in db.ItemMa
我正在尝试使用 antlr 3 为我的语法生成词法分析器和解析器。有人可以解释这个错误是什么意思吗? error(211): T.g:14:6: [fatal] rule stmt has non-L
partykit包很好地表示了决策树。我遇到的唯一问题是标签很长然后它们重叠。是否可以移动这些标签以防止它(见下图中的蓝色箭头)? library("rpart") library("partykit
所以我环顾四周,似乎找不到合适的解决方案来解决我的问题。 问题 在我的布局中,我希望能够根据数据库中的内容选择在运行时是否存在导航项: 当前布局(导航栏) @Html.Acti
我目前正在创建一个机器学习 jupyter 笔记本作为一个小项目,并希望显示我的决策树。但是,我能找到的所有选项都是导出图形然后加载图片,这相当复杂。 所以想问问有没有办法不用导出加载图形,直接显示我
grammar AdifyMapReducePredicate; PREDICATE : PREDICATE_BRANCH | EXPRESSION ; PREDICA
我是一名优秀的程序员,十分优秀!