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
0
votes
0 answers

Error box.col: illegal value on fancyRpartPlot() and rpart.plot() in R

I am practising the tutorial of 'Titanic: Machine Learning from Disaster' from kaggle. Could someone please help me with this error ? Its same for the function rpart.plot(fit) and fancyRpartPlot(fit) and example(rpart.plot), While plot(fit) is…
Renil Joseph
  • 163
  • 3
  • 11
0
votes
0 answers

How do I transform an rpart object (result of rpart() function) into a data frame?

I have a data set (let's call it "x") that looks like this... x <- structure(list(top_bracket_style = c("29L", "23R", "29L", "29R", "29R", "29L", "29R", "29R", "29R", "29R", "29R", "29R", "29R", "29L", "90"), column_finish = c("PT", "AW", "PT",…
Eric
  • 3
  • 2
0
votes
1 answer

A decision tree algorithm with a way to club the many levels of a categorical variable into 2 groups

I have a file which has data on customers defaulting on loans or not. There are many variables in this file. One such variable is "customer.employername". This variable has around 1000+ unique values of employer names of the customers. I want to use…
Rookie
  • 45
  • 2
  • 8
0
votes
1 answer

r rpart only working for integers and not factors? getting a tree with no depth

I'm having a few issues running a simple decision tree within R using rpart. I can't post my actual data for an example because of confidentiality, but here's the structure. I've blanked out a load of bits just because I've got my tin foil hat on…
roastbeeef
  • 1,039
  • 1
  • 12
  • 23
0
votes
1 answer

What mean extra=101 information in rpart plot?

What mean each number with slashes between them (my plot) when is used the parameter extra=101, the documenttion said "Display the number of observations that fall in the node (per class for class objects; prefixed by the number of events for…
0
votes
1 answer

Using tm and rpart in R: decision tree for textual data?

I am using the tm package in R to create a corpus of text documents and I would like to create a decision tree with rpart for classification purposes. However, I can't find any examples on the internet about using textual data with rpart. Is it even…
vdvaxel
  • 667
  • 1
  • 14
  • 41
0
votes
1 answer

How can I get the data in one terminal node of a decision tree in RPART

Suppose I have a decision tree from rpart, How can I get all the data points in one node without writing all the conditions? For example, How can I get 17 data points in Node 3, without writing if else on all…
hxd1011
  • 885
  • 2
  • 11
  • 23
0
votes
1 answer

I get an error [invalid type (list) for variable '(weights)'] while using the rpart function for decision trees in R

These are the commands I am using in R: Outcome_factor= factor(train$Outcome) rpart_model= rpart(Outcome_factor~., data=train, method='class',rpart.control(minsplit = 2, cp = 0)) The dataset "train" has the variables: Outcome,Pregnacies, Glucose,…
Preyas
  • 773
  • 1
  • 7
  • 12
0
votes
3 answers

Data manipulation makes lapply not work

EDIT: Ok, it has something to do with the data.all.filtered datatype. The filtered datatype gets created from data.all.raw which works fine with any lapply below. The weird thing is that I can't find out how do the two…
Petrroll
  • 741
  • 7
  • 29
0
votes
0 answers

How do I make my tree plot in R to be less messy, so I can see the outcomes of the visualization? (image provided)

I am using the rpart package in r studio. I'm not sure if I need to reduce the font, spread the branches out more, or do some type of pruning? c.tree1 <- rpart(certified ~ grade + forum.posts + assignment, method="class",…
0
votes
1 answer

Rpart split error: Agument split not matched

I want to change the splitting method in rpart function from "gini" (which is default) to "information". In the help section we have this example: fit2 <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis, parms = list(prior =…
itsame
  • 1
  • 1
0
votes
1 answer

Rpart equivalent to LM's se.fit

I have 2 regression models in R: LM model in which I use the se.fit=true as follows: predict(my_model, newdata=data, se.fit=T) Recursive Portioning Tree (using rpart package) Unfortunately I don't have the se.fit option in rpart, and I'd like to…
Guy Dubrovski
  • 1,542
  • 1
  • 20
  • 25
0
votes
1 answer

How do i create a simple tree with rpart?

I'm trying to create a decisiontree in R with rpart. #rm(list = ls()) cat("\014") library("rpart") #data mf <- factor(c("m","m","f","f","m","f","m")) heights <- c(180, 175 , 160, 166, 185, 170, 190) x = data.frame(cbind(heights, mf)) #create…
0
votes
1 answer

Rpart: sensitivity for general rules with poor predictors

I hope this isn't too vague but I am building a decision tree with a big class imbalance (1% hit rate) and some poor predictors. The default settings for Rpart don't even split the tree, trying to change the sensitivity (cp) does so something but it…
khhc
  • 93
  • 2
  • 11
0
votes
1 answer

Error training with caret method rpart R

I'm having and error while trying to train a dataset with the caret package. The error is the following... Error in train.default(x, y, weights = w, ...) : Stopping. I also have warnings() which all of them are the same because I'm creating an…
redeemefy
  • 4,521
  • 6
  • 36
  • 51