Questions tagged [rpart]

An R package for fitting classification and regression trees.

rpart is an package for fitting and trees ().

Repositories

Vignettes

Other resources

Related tags

445 questions
2
votes
1 answer

How can I change plotted numbers from scientific notation to standard form in an rpart regression tree plot?

I am using the rpart.plot package to plot a regression tree. How can change the numbers from scientific notation into standard form at the bottom of the tree? For example, I want to change 14e+3 to 14000. This is the code I am…
2
votes
1 answer

Rpart vs. caret rpart "Error: There were missing values in resampled performance measures"

I use the caret package and tried to use the rpart method. Interestingly, I can fit a model with the general rpart package, but as soon as I use the caret package, it no longer works. What further puzzles me is that I have seen on various websites…
carl
  • 305
  • 2
  • 13
2
votes
1 answer

Colour nodes in rpart.plot by list of colours matching nodes

In the function rpart.plot (from the package rpart.plot, extension to the rpart package) there is the argument box.col, which controls the colour of the nodes in the tree. How do I set it such that it colours the nodes so that nodes of the same…
Beavis
  • 476
  • 3
  • 13
2
votes
2 answers

How do I plot the Variable Importance of my trained rpart decision tree model?

I trained a model using rpart and I want to generate a plot displaying the Variable Importance for the variables it used for the decision tree, but I cannot figure out how. I was able to extract the Variable Importance. I've tried ggplot but none of…
2
votes
1 answer

error running decision tree models with `caret` package

I am trying to write decision tree models using the caret package and can't get it to work. First I wanted to see if the model works with rpart package where I can run the identical model and it does- #…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
2
votes
0 answers

Select among predictors with equal improvement

I try to implement RPART in order to make some developments later. So far only for regression (ANOVA) model. Everything seems pretty clean except one thing — how RPART selects best split among several predictors with identical improvement. For…
2
votes
1 answer

Save rpart decision tree rules to a dataframe

I am using rattle::asRules() to display rpart decision rules to the screen, my goal is to save the rules to a tidy data frame. Here is an example: library(rpart) library(rattle) fit <- rpart(Kyphosis ~ Age + Number + Start, data =…
ronencozen
  • 1,991
  • 1
  • 15
  • 26
2
votes
1 answer

Rpart predicts both 0 and 1 for every observation in test set

Here is the scenario: library(rpart); library(dplyr); library(caret) data <- read.csv("NetworkIntrusionValidatedata.csv") #50 example rows provided below traindata <- createDataPartition(y,p=0.9,list = F) %>% c() train <- data[traindata,] test <-…
2
votes
2 answers

how derive standard deviation of the leaf nodes (rpart)?

I have done a regression tree with rpart to assess the walking of elderly people based on a few variables. With the use of the plot I would like to use the output for further analysis in another software. However I was wondering whether it would be…
Joy
  • 93
  • 1
  • 12
2
votes
2 answers

Reshape binomial data to long bernoulli format

I am coming back to R after a year and want to use rpart for a classification tree. My data looks like: Category, Shape, Color, Yes, No A, Square, Blue, 3, 2 B, Triangle, Blue, 2, 4 etc. Any recommendations to reshape into the below so I can use…
As3adTintin
  • 2,406
  • 12
  • 33
  • 59
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
0 answers

How to become the gini-index for each possible first split using CART in R (package rpart)

I have a huge Dataset with more than 125 variables. I am applying a CART (Classification and regression tree). What I am missing is a list of all possible first splits, with the referring gini-values (If you apply a CART in SAS, you become such a…
2
votes
1 answer

Clarification of decision tree surrogate splits

I have a question regarding the output of an rpart classification tree in R. Where there is missing values, a surrogate split is used. Here is an example. Surrogate splits: ## bmi < 21.51 to the right, agree=0.858, adj=0.632, (0…
2
votes
0 answers

Difference between using Prune function to tune the tree and set the tuned parameters in rpart

When we found the tuned parameters(e.g. the CP or maxdepth), what is the difference between using Prune function to tune the tree and set the tuned parameters in rpart? i.e. What is the difference between prune(tree,cp=best_cp,maxdepth=best_cp)…
wong david
  • 43
  • 2
  • 5
2
votes
1 answer

Inconsistent results from R-part package

I am running R part on the same data set but the order of the columns are different and I am getting different results. This is my dataset Home.Owner Marital.Status Annual.Income Default 1 Yes Single 125 No 2 …
Akshay Kadidal
  • 515
  • 1
  • 7
  • 15