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

415 questions
0
votes
0 answers

decision tree - customize plot title when using Rattle and rpart.plot

I created a decision tree using Rattle and the rpart.plot package. This package is supposed to make the output more "pretty" than the regular Rattle output. Here's what the output looks like. My Question: I don't like how the default title (top…
thanks_in_advance
  • 2,326
  • 5
  • 19
  • 39
0
votes
1 answer

Problems with prediction in decision tree in caret package

I am having problems doing a prediction with decision trees (CART). I have this code: training <- read.csv("pml-training.csv", header=TRUE) set.seed(1972) inTrain <- createDataPartition(y=training2$classe, p=0.6, list=FALSE) wk_training <-…
0
votes
1 answer

pruning tree with caret library returns complex trees

I'm using the caret package for a tree model. I understood that caret uses CV to find the optimal tuning parameter for pruning the tree. This is the code I use: id2 <- sample(1:nrow(data),2/3*nrow(data)) #learn app <- data[id2,] #test test <-…
Charlotte
  • 307
  • 1
  • 2
  • 13
0
votes
1 answer

How to do decision trees in R?

I usually do decissions trees in SPSS to get targets from a DDBB, I did a bit of research and found that there are three packages: tree, party and rpart that are available for R, but which is better for that task? Thanks!
JJ1603
  • 496
  • 1
  • 5
  • 16
0
votes
1 answer

Gibberish Output in RPart plot in R

I am trying to run a Decision Tree using RPart in R, on a data set with 26 variables to classify an outcome as 0 or 1. The model has a fair accuracy of 81% and when I go ahead and plot the tree, I get very gibberish variable splitting values. Ex:…
Anurag H
  • 777
  • 10
  • 22
0
votes
1 answer

Error in confusionMatrix.default(data.testTree, testing$money.gain) : the data cannot have more levels than the reference

No, because when you run caret::confusionMatrix (data.testTree, testing $ money.gain) tells me this: the data can not have any more than the reference levels. I have run these commands: cvControl <- trainControl(method = "repeatedcv" number = 10,…
LuisoBKM
  • 1
  • 1
0
votes
1 answer

How to return multiple objects of a library in R?

I'm using rpart library in R. In a function, I want to return an array of rpart objects which are generated in a for loop. However, I don't know which data structure I should use for storing rpart objects. Each of the rpart objects has many values.…
Pegah
  • 111
  • 11
0
votes
0 answers

How can I get a plot in rpart to use observed values rather than weights

I've successfully completed an analysis in rpart, where I have 0-1 outcome data, where I have weighted the data to deal with the problem of a scarce response. When I plot the data using prp, I want the labels to have the true proportion, rather than…
0
votes
0 answers

R rpart model has zero splits after using caret's train

I am using rpart to get a classification model for my data but I do not know how to allocate the bucket size so as to avoid getting an overfitted or underfitted model. To get the optimal bucket size, I read that using caret's package train method…
Guanhua Lee
  • 147
  • 1
  • 10
0
votes
2 answers

Caret and rpart - definining method

i am trying to familiarize myself with the caret package. I would previously use rpart directly - e.g. with the following syntax fit_rpart=rpart(y~.,data=dt1,method="anova"). i have specified anova as i am aiming for regression (rather than…
user1885116
  • 1,601
  • 3
  • 22
  • 38
0
votes
1 answer

not creating tree by rpart in R

I'm new to R and rpart package. I want to create a tree using the following sample data. My data set is similar to this mydata…
0
votes
1 answer

How to find the the deviance of an as.party object converted from rpart tree in R?

I created a tree in R. rp <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis) ## coerce to `constparty' rp.party <- as.party(rp) Now, I want to find the deviance of the rp.party object. Is there a way to do so without going to the rp…
0
votes
1 answer

Getting back original names from rpart.object

I have saved models which were created using the rpart package in R. I am trying to retrieve some information from these saved models; specifically from rpart.object. While the documentation - rpart doc - is helpful there are a few things it is not…
abhgh
  • 308
  • 1
  • 9
0
votes
1 answer

The meaning of predict(rpart.model)

Given that: data(iris) fit <- rpart(Species~., iris) predict(fit) Does this give a cross-validated prediction of the training data? I did not find any confirmation for a CV prediction in the rpart documentation. 10x
Guest3290
  • 157
  • 8
0
votes
1 answer

Getting error "variable lengths differ (found for 'columns_features')" in R

I am applying rpart function to a data frame named train having all the integer values. There are too many features so for that I have created a formula. columns_features <- (paste(colnames(train)[31:50], collapse = "+")) formulas <-…
Ronak Shah
  • 286,338
  • 16
  • 97
  • 143