party

Generate table with side-by-side node models of `partykit:mob()` object

有些话、适合烂在心里 提交于 2021-02-18 07:51:08
问题 Let's say I fit a model using partykit:mob() . Afterward, I would like to generate a side-by-side table with all the nodes (including the model fitted using the whole sample). Here I attempted to do it using stargazer() , but other ways are more than welcome. Below an example and attempts to get the table. library("partykit") require("mlbench") ## Pima Indians diabetes data data("PimaIndiansDiabetes", package = "mlbench") ## a simple basic fitting function (of type 1) for a logistic

partykit: Modify terminal node to include standard deviation and significance of regressors

北城余情 提交于 2021-02-10 16:01:31
问题 I would like to be able to personalize the plot that it is displayed to include standard deviation and statistical significance of the regressors after using the partykit::mob() function. The following code is from partykit documentation. library("partykit") if(require("mlbench")) { ## Pima Indians diabetes data data("PimaIndiansDiabetes", package = "mlbench") ## a simple basic fitting function (of type 1) for a logistic regression logit <- function(y, x, start = NULL, weights = NULL, offset

partykit: Modify terminal node to include standard deviation and significance of regressors

本秂侑毒 提交于 2021-02-10 16:00:32
问题 I would like to be able to personalize the plot that it is displayed to include standard deviation and statistical significance of the regressors after using the partykit::mob() function. The following code is from partykit documentation. library("partykit") if(require("mlbench")) { ## Pima Indians diabetes data data("PimaIndiansDiabetes", package = "mlbench") ## a simple basic fitting function (of type 1) for a logistic regression logit <- function(y, x, start = NULL, weights = NULL, offset

partykit - How to plot a glmtree without overlapping of terminal nodes?

我是研究僧i 提交于 2021-02-10 14:41:54
问题 I would like to plot a tree resulting from glmtree (partykit package). Unfortunately, the terminal nodes are overlapping and the labels of the graphs are no longer displayed properly. The code that generates the tree is this one: library(partykit) library(aVirtualTwins) data(sepsis) attach(sepsis) data <- cbind(y = survival, trt = as.factor(THERAPY), sepsis[,3:13]) formula <- as.formula(paste("y ~ trt", paste(names(sepsis[,3:13]), collapse = " + "), sep = " | ")) fit <- glmtree(formula, data,

cforest party unbalanced classes

十年热恋 提交于 2021-01-27 08:59:27
问题 I want to measure the features importance with the cforest function from the party library. My output variable has something like 2000 samples in class 0 and 100 samples in class 1. I think a good way to avoid bias due to class unbalance is to train each tree of the forest using a subsample such that the number of elements of class 1 is the same of the number of element in class 0. Is there anyway to do that? I am thinking to an option like n_samples = c(20, 20) EDIT: An example of code >

partykit: justify text in terminal node when unequal regressors' name lengths are included

对着背影说爱祢 提交于 2021-01-05 07:29:29
问题 I am trying to edit the esthetics of the terminal node to: Increase the size of the box such that the full names are listed inside of it. If possible, justify the text inside when in the presence of unequal regressors' name lengths to produce a table-like view of the terminal nodes. Below I listed my attempts, using the gp option (fontsize = 10, boxwidth = 10) , but I suspect that I am using the wrong esthetics options. The mysummary function is highly inspired in this question. library(

partykit: justify text in terminal node when unequal regressors' name lengths are included

喜你入骨 提交于 2021-01-05 07:26:46
问题 I am trying to edit the esthetics of the terminal node to: Increase the size of the box such that the full names are listed inside of it. If possible, justify the text inside when in the presence of unequal regressors' name lengths to produce a table-like view of the terminal nodes. Below I listed my attempts, using the gp option (fontsize = 10, boxwidth = 10) , but I suspect that I am using the wrong esthetics options. The mysummary function is highly inspired in this question. library(

Plot of BinaryTree (ctree, party) ignores plot option of par()

安稳与你 提交于 2020-08-07 05:06:13
问题 I would like to plot the BinaryTree in the uppper part of the plot, and make a second one in the second part (bottom). Here is some example code to show, that the plot of the tree completely ignores the partitioning options set by par() library("party") ### regression airct <- ctree(Ozone ~ ., data = subset(airquality, !is.na(Ozone))) ### classification irisct <- ctree(Species ~ .,data = iris) par(mfrow = c(2, 1)) plot(airct) plot(irisct) This code does not plot the two trees in the same plot

R update ctree (package party) features factors levels

本秂侑毒 提交于 2020-01-25 18:26:25
问题 I am trying to make sure that all my features of type factors are represented fully (in terms of all possible factor levels) both in my tree object and in my test set for prediction. for (j in 1:length(predictors)){ if (is.factor(Test[,j])){ ct [[names(predictors)[j]]] <- union(ct$xlevels[[names(predictors)[j]]], levels(Test[,c(names(predictors)[j])])) } } however, for object ct (ctree from package party) I can't seem to understand how to access the features' factor levels, as I am getting an

R update ctree (package party) features factors levels

孤人 提交于 2020-01-25 18:25:11
问题 I am trying to make sure that all my features of type factors are represented fully (in terms of all possible factor levels) both in my tree object and in my test set for prediction. for (j in 1:length(predictors)){ if (is.factor(Test[,j])){ ct [[names(predictors)[j]]] <- union(ct$xlevels[[names(predictors)[j]]], levels(Test[,c(names(predictors)[j])])) } } however, for object ct (ctree from package party) I can't seem to understand how to access the features' factor levels, as I am getting an