Questions tagged [party]

Questions related to the R packages party and partykit for recursive partitioning

The R packages party and its successor partykit provide a toolbox for recursive partitioning for a variety of regression models. See the manual and vignettes for more details.

240 questions
2
votes
1 answer

Is it possible to build a random forest with model based trees i.e., `mob()` in partykit package

I'm trying to build a random forest using model based regression trees in partykit package. I have built a model based tree using mob() function with a user defined fit() function which returns an object at the terminal node. In partykit there is…
Kiran KG
  • 33
  • 4
2
votes
1 answer

terminal panel partykit r node id plots object info

I'm trying to remove the labels of the Node id's at the terminal panel of a partykit object (those that say Node x...), following the instructions with terminal_panel, I can change the inner_panel without trouble, but the plot includes information…
Elio Diaz
  • 566
  • 2
  • 19
2
votes
1 answer

R partykit: How do I use the offset?

I am trying to predict the frequency of an outcome and I have a lot of data. I have already fitted a glm to the data and now I am trying to use ctree to understand any complex interaction in the dataset that I may have missed. Instead of directly…
CHF18
  • 23
  • 4
2
votes
1 answer

partykit: Change terminal node boxplots to bar graphs that shows mean and standard deviation

I have created a regression tree in R. Here's the code: tree <- rpart(y~., method="anova", minsplit=20, minbucket=20, maxdepth=3, data=foo) plot(as.party(tree), terminal_panel = node_boxplot) Instead of a boxplot, which shows the median and IQR,…
aleia
  • 59
  • 5
2
votes
2 answers

ctree function in party package - how to get the list of the splitting variable in a simple way

I am trying to get the list of the splitting variable of a tree when using ctree. I found a way to get a specific splitting variable of a specific node using psplit. But I would like to get the whole list of the splitting variables in the entire…
user573347
  • 975
  • 1
  • 7
  • 11
2
votes
1 answer

Issue with caseweights and OOB prediction using cforest from the party package

I am fitting a cforest with the optional argument caseweights, which is a double matrix with ncol(caseweights)== number of trees in my random forest and nrow(caseweights)= number of observations. Furthermore I am normalizing them so that the colSums…
franzfranz
  • 23
  • 4
2
votes
2 answers

Conditional partitioning

I would like to partition a variable V2 using a variable V1. And V1 depends on a third variable V3. In the following R code the variable V1 depends on a variable V3 such as when V3 equals 10 and V2 is 1, V1 equals 1. Is there an algorithm which is…
MassCorr
  • 349
  • 1
  • 8
2
votes
1 answer

R - partykit - custom model tree nodes and splits

In package partykit there is a way to build custom trees by specifying predictor and split. For example: data("WeatherPlay", package = "partykit") #create a split sp_o <- partysplit(3L, breaks = 75) #create a node n1 <- partynode(id = 1L, split =…
2
votes
1 answer

How to fix "invalid type (NULL) for variable" error in ctree function using the party package in R?

I am using the ctree() in the party package from R. I want to be able to columns from more than one dataframe, for which I would call use column separately (using $) as I have in the past with this function but this time it is not working. For the…
user3386170
  • 276
  • 4
  • 22
2
votes
1 answer

Rotate x-axis of r partykit tree plot

I've built a decision tree using ctree in R and visualize the tree using the ctree model in the party package. I am very happy with the results and the overall visualization. However, I cannot interpret the 'confusion' in every leaf node, since the…
Arend
  • 313
  • 2
  • 4
2
votes
1 answer

How to get the surrogate splits in a ctree model, party package in R

I am trying to use ctree from party to get a conditional classification tree. The tree worked well, but I just can't find any infomation about how to see the results of the surrogete splits from this tree. The script for the model…
phil
  • 75
  • 7
2
votes
1 answer

cforest: error in predict when newdata is one-row dataframe

Hello I am using the package partykit and its function cforest to fit a model. I can also use predict to predict based on a multi-row dataframe. However, I cannot predict on a dataframe with one row. require('partykit') y <-…
2
votes
1 answer

Can't get partykit package's mob function to do univariate MLE fit

I can't get the partykit package's mob function to do univariate MLE fit. # Trying to convert vignette example here https://cran.r-project.org/web/packages/partykit/vignettes/mob.pdf on page 7 to do univariate MLE gamma fits. …
rwinkel2000
  • 136
  • 9
2
votes
0 answers

Traversing a Binary Tree to Get The Splitting Conditions - ctree(party), recursive function

I am trying to reproduce the error which I get with my dataset using a general dataset. Please correct me if I am missing something. After fitting a Classification tree using library(party), I am trying to get the split conditions of the tree on…
user3560220
  • 221
  • 3
  • 4
  • 11
2
votes
2 answers

Depth of a node in partykit

I am building a tree using the partykit R package, and I am wondering if there is a simple, efficient way to determine the depth number at each internal node. For example, the root node would have depth 0, the first two kid nodes have depth 1, the…