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
33
votes
6 answers

Warning message: "missing values in resampled performance measures" in caret train() using rpart

I am using the caret package to train a model with "rpart" package; tr = train(y ~ ., data = trainingDATA, method = "rpart") Data has no missing values or NA's, but when running the command a warning message comes up; Warning message: In…
USER_1
  • 2,409
  • 1
  • 28
  • 28
32
votes
1 answer

How to compute error rate from a decision tree?

Does anyone know how to calculate the error rate for a decision tree with R? I am using the rpart() function.
teo6389
  • 523
  • 1
  • 5
  • 10
25
votes
3 answers

How to make a tree plot in caret package?

I'm using caret package to model the data using rpart package. library('caret') data(iris) formula <- as.formula(Species ~.) t <- train(formula,iris,method = "rpart",cp=0.002,maxdepth=8) plot(t) As a result I get object 't' and I'm trying to plot…
Jot eN
  • 6,120
  • 4
  • 40
  • 59
20
votes
4 answers

R: plotting decision tree labels leaves text cut off

(I'm still learning how to handle images in R; this is sort of a continuation of rpart package: Save Decision Tree to PNG ) I'm trying to save a decision tree plot from rpart in PNG form, instead of the provided postscript. My code looks like this:…
rhae66
  • 293
  • 1
  • 4
  • 8
19
votes
3 answers

The result of rpart is just with 1 root

As in my dataset ,the Leakage have two value 1,0. There are just about 300 rows with 1 and extra in 569378 rows are with 1. This would be the reason that I just got 1 root in the rpart result. How can I solve this? fm.pipe<-Leakage~PipeAge…
user3172776
  • 211
  • 1
  • 3
  • 5
19
votes
4 answers

Error in eval(expr, envir, enclos) : object not found

I cannot understand what is going wrong here. data.train <- read.table("Assign2.WineComplete.csv",sep=",",header=T) # Building decision tree Train <- data.frame(residual.sugar=data.train$residual.sugar, …
Rads
  • 345
  • 1
  • 4
  • 11
15
votes
3 answers

Regression tree in R

I am having trouble making a regression tree in R. I have a data frame with 17 attributes library(rpart) rt.model <- rpart(razlika ~ ., learn) I get an error: Error in `[.data.frame`(frame, predictors) : undefined columns selected Seems weird…
Borut Flis
  • 15,715
  • 30
  • 92
  • 119
14
votes
2 answers

Using a survival tree from the 'rpart' package in R to predict new observations

I'm attempting to use the "rpart" package in R to build a survival tree, and I'm hoping to use this tree to then make predictions for other observations. I know there have been a lot of SO questions involving rpart and prediction; however, I have…
jwdink
  • 4,824
  • 5
  • 18
  • 20
14
votes
1 answer

How to prune a tree in R?

I'm doing a classification using rpart in R. The tree model is trained by: > tree <- rpart(activity ~ . , data=trainData) > pData1 <- predict(tree, testData, type="class") The accuracy for this tree model is: >…
zfz
  • 1,597
  • 1
  • 22
  • 45
13
votes
1 answer

Caret train method complains Something is wrong; all the RMSE metric values are missing

On numerous occasions I've been getting this error when trying to fit a gbm or rpart model. Finally I was able to reproduce it consistently using publicly available data. I have noticed that this error happens when using CV (or repeated cv). When I…
Fred R.
  • 557
  • 3
  • 7
  • 16
12
votes
1 answer

result of rpart is a root, but data shows Information Gain

I have a dataset with an event rate of less than 3% (i.e. there are about 700 records with class 1 and 27000 records with class 0). ID V1 V2 V3 V5 V6 Target SDataID3 161 ONE 1 FOUR 0 0 SDataID4 11 TWO 2 …
10
votes
3 answers

Applying k-fold Cross Validation model using caret package

Let me start by saying that I have read many posts on Cross Validation and it seems there is much confusion out there. My understanding of that it is simply this: Perform k-fold Cross Validation i.e. 10 folds to understand the average error across…
pmanDS
  • 193
  • 1
  • 2
  • 10
10
votes
1 answer

Get decision tree rule/path pattern for every row of predicted dataset for rpart/ctree package in R

I have built a decision tree model in R using rpart and ctree. I also have predicted a new dataset using the built model and got predicted probabilities and classes. However, I would like to extract the rule/path, in a single string, for every…
arindam adak
  • 101
  • 1
  • 6
10
votes
1 answer

Data Prediction using Decision Tree of rpart

I am using R to classify a data-frame called 'd' containing data structured like below: The data has 576666 rows and the column "classLabel" has a factor of 3 levels: ONE, TWO, THREE. I am making a decision tree using rpart: fitTree =…
Saba Jamalian
  • 750
  • 2
  • 10
  • 24
9
votes
2 answers

Decision tree using continuous variable

I have a question about Decision tree using continuous variable I heard that when output variable is continuous and input variable is categorical, split criteria is reducing variance or something. but I don't know how it work if input variable is…
BSKim
  • 91
  • 1
  • 1
  • 2
1
2 3
29 30