简体   繁体   English

如何在MOB树的每个节点中找到观测值? (partykit软件包)

[英]How to find the observation in each node of the MOB tree? (partykit package)

I have used the partykit package to create a Model-Based Partitioning (MOB) tree on a dataset and I wondered if there was a way to see which observations in our dataset pass that rules and fall in each node. 我已经使用partykit包在数据集上创建了基于模型的分区(MOB)树,我想知道是否有一种方法可以查看数据集中的哪些观测值通过该规则并落入每个节点。 (I want to have separate data frame for each node base on the tree rules). (我想基于树规则为每个节点设置单独的数据框)。

You can use predict(..., type = "node") for all partykit trees to obtain the predicted terminal node ID. 您可以对所有partykit树使用predict(..., type = "node")以获取预测的终端节点ID。 And then you can use that for split() ting the data set. 然后,您可以将其用于split()设置数据集。 For example: 例如:

library("partykit")
tr <- lmtree(dist ~ speed, data = cars)
plot(tr)

lmtree

split(cars, predict(tr, type = "node"))
## $`3`
##    speed dist
## 1      4    2
## 2      4   10
## 3      7    4
## 4      7   22
## 5      8   16
## 6      9   10
## 7     10   18
## 8     10   26
## 9     10   34
## 10    11   17
## 11    11   28
## 12    12   14
## 13    12   20
## 14    12   24
## 15    12   28
## 
## $`4`
##    speed dist
## 16    13   26
## 17    13   34
## 18    13   34
## 19    13   46
## 20    14   26
## 21    14   36
## 22    14   60
## 23    14   80
## 24    15   20
## 25    15   26
## 26    15   54
## 27    16   32
## 28    16   40
## 29    17   32
## 30    17   40
## 31    17   50
## 
## $`5`
##    speed dist
## 32    18   42
## 33    18   56
## 34    18   76
## 35    18   84
## 36    19   36
## 37    19   46
## 38    19   68
## 39    20   32
## 40    20   48
## 41    20   52
## 42    20   56
## 43    20   64
## 44    22   66
## 45    23   54
## 46    24   70
## 47    24   92
## 48    24   93
## 49    24  120
## 50    25   85

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 mob() 树(partykit 包)与 nls() 模型一起使用 - Using mob() trees (partykit package) with nls() model 使用 mob() 树(partykit 包)和logistic() model - Using mob() trees (partykit package) with logistic() model 使用 `partykit:mob()` object 的并排节点模型生成表 - Generate table with side-by-side node models of `partykit:mob()` object 在partykit包中修改ctree()中的终端节点 - Modifying terminal node in ctree(), partykit package 无法获得partykit包的mob函数来进行单变量MLE拟合 - Can't get partykit package's mob function to do univariate MLE fit 是否可以使用基于模型的树(即 partykit 包中的“mob()”)构建随机森林 - Is it possible to build a random forest with model based trees i.e., `mob()` in partykit package Montecarlo Simulation 使用 mob() 算法(partykit 包)来恢复正确识别模型的数量 - Montecarlo Simulation using mob() algorithm (partykit package) to recover the count of the correctly identified models 如何以partykit格式获取txt树的孩子 - How to get the kids of a txt tree in partykit format 如何在R中的partykit / glmertree包的绘图功能中缩小内部节点的表示形式? - How can I make the internal node representation smaller in the plotting function of the partykit/glmertree package in R? partykit:回归树-识别终端节点盒图中的异常值 - partykit: regression tree - identify outliers in terminal node boxplots
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM