`rpart` is an R package that provides a number of routines related to regression trees and recursive partitioning algorithms. This package is frequently used for classification problems.

learn more… | top users | synonyms

0
votes
0answers
4 views

Specifying negative costs (benefits) in rpart's loss matrix

How do we specify negative costs in rpart? The documentation says the diagonals of the loss matrix should be zero. Is there an alternative to specify the benefits of correct classification (that is, ...
3
votes
0answers
46 views

Propensity score matching: using alternative methods to create a distance measure

I would like to use a greedy nearest neighbour method to do propensity score matching. Though I've little experience here, it seems that the distance measure used is generally a propensity score ...
0
votes
0answers
24 views

How are CP (Cost Complexity) values calculated in RPART (or decision trees in general)

From what I understand, the cp argument to the rpart function helps pre-prune the tree in the same way as the minsplit or minbucket arguments. What I don't ...
0
votes
0answers
11 views

How does RPART pick a splitter when there are at least 2 splits having maximal information gain?

I'm not sure the best way to explain this, so let me give an example that motivates my question. I have tried reading the RPART manual, documentation, and its code, but I have not been able to resolve ...
0
votes
1answer
57 views

difference between rel error and xerror regression trees (rpart)

Wondering what the difference is between rel error (relative error) and xerror (apparent error) in regression trees? I am using the rpart package and the output returns these metrics ...
1
vote
0answers
19 views

Find the data elements in a data frame that pass the rule for a node in a tree model?

So I have used the rpart package to create a tree model and I found an interesting rule and wondered if there was an easy way to see which observations in that data frame pass that rule. It seems ...
1
vote
1answer
85 views

How do I specify a loss matrix in rpart?

I have a basic question - how to I set up a loss matrix to weigh the cost of a false positive higher than a false negative? I am trying to produce a tree in rpart to classify a disease with high ...
1
vote
2answers
204 views

Decision Tree - Splitting Factor Variables

I'm new to decision trees and I have some confusion about how factor variables and non-ordered character/string variables get handled in a split. Suppose I have a factor such as "tiny, small, medium, ...
0
votes
0answers
53 views

Rpart and tree models — cross validation beyond cp value

I normally cross-validate my tree-models (rpart) only on cp-value, e.g. by using caret or xpred or the internal rpart cross validation function. However, there are other rpart parameters -- for ...
0
votes
0answers
31 views

Rpart cross-validation errror

Despite reading the rpart technical documentation, it is still unclear to me how the cross-validation error (xerror) is computed. Using the standard 10 fold cross-validation, does that mean a) ...
0
votes
0answers
205 views

R rpart cross validation and 1 SE rule, why is the column in cptable called “xstd”?

The rpart() function in R returns cptable that includes columns xerror and xstd. Here is an arbitrary example. ...
0
votes
1answer
111 views

Using Rpart to find which factor influence the outcome the most

I have 3 factors x1, x2, x3, and one outcome y (True, False). x1 has 3 levels, x2 has 40 levels, x3 has 2 levels. I would like to find which parameter (x1, x2, or x3) and associated levels influence ...
0
votes
1answer
54 views

Predicting outcomes where there's no data in rpart

I have a data set with about ~2000 data points. Of these ~1000 actually have features/data. (All 2000 data points have an outcome) Where there's no data, there is very likely a signal. In other ...
2
votes
2answers
478 views

Regression tree algorithm with linear regression models in each leaf

Short version: I'm looking for an R package that can build decision trees whereas each leaf in the decision tree is a full Linear Regression model. AFAIK, the library ...
1
vote
1answer
235 views

Control parameter minsplit for rpart in regression tree

I processed rpart( ) on the same dataset. One did not use the control parameter "minsplit", but the other one did. I do not understand why I got the different first node in two processes. My ...
0
votes
0answers
64 views

Classification tree with rpart package

I am using R with package tree to build a classification tree to summarize and represent my data. I have only 27 records and 10 variables. I built the tree but the ...
0
votes
1answer
61 views

rpart maximum input states

I am using rpart for decision tree models and if my dataset has columns with around more than 25 factors/levels , rpart gets stuck and runs indefinitely. So i just wanted to know if there is this is a ...
0
votes
0answers
114 views

How to find Variance from rpart object in R

I am fairly new to R and am creating an rpart object using the method "anova" (Since I am dealing with continuous columns) ...
0
votes
1answer
90 views

Priors and Loss in R

I am fairly new to R and data mining concepts and am trying to understand the rpart package in R. I am a bit confused about the role of priors and loss in the ...
0
votes
2answers
122 views

CART for regression: Avoid impossible combinations

I want to predict a categorical variable using also categorical predictors. Currently, I am looking at classification and regression trees (CART). The prediction quality is "good enough", except for ...
2
votes
2answers
2k views

How to use rpart's result in prediction

This may be a simple question but I stuck in this problem. I am using Recursive Partitioning (rpart) package in R for building a classification tree. I generated a tree from a sample data (for testing ...
0
votes
0answers
55 views

Rpart confidence interval

Is there any way to compute 95% confidence intervals and prediction interval for the predicted value at each node? Thanks!!!
0
votes
1answer
154 views

Loss Matrix Equivalent with Neural Networks and random Forest

I'm doing classification (0,1) on a dataset for which different types of errors should be weighted differently. IE, false positives would be weighted 10 x more than false negatives. In decision ...
0
votes
0answers
56 views

Various models not improving basic rpart result

I have a data set with 10,000 or so samples in it and 100 or so features. I've created a training set and test set and am trying to predict a numeric value. I've used rpart to determine the most ...
3
votes
1answer
268 views

how does rpart handle missing values in predictors?

From the ?rpart documentation - na.action : the default action deletes all observations for which y is missing, but keeps those in which one or more predictors ...
0
votes
1answer
229 views

Understanding factors returned by RPart classification

This is a very basic question on using R for classification. I'm trying to use rpart for classification task and would like to have a class label as a result, i.e. I use type="class" in predict method ...
5
votes
0answers
2k views

Choosing complexity parameter in CART

In the rpart() routine to create CART models, you specify the complexity parameter to which you want to prune your tree. I have seen two different recommendations for choosing the complexity ...
2
votes
0answers
317 views

Is it possible to have xerror increased in a tree using rpart?

I am new to R and rpart package. When I plot the tree using rpart: ...
0
votes
0answers
140 views

CART with rpart and a 12 level factor

I have a 12-level factor variable (month) in my dataset and I wanted to fit a CART tree with rpart(). Would you split the 12-level factor variable into 12 dummy variables? If I fit the model with one ...
2
votes
1answer
2k views

rpart and the printcp function

I don't really understand how the columns "xerror" and "rel error" are calculated. I found out that the printcp() function "gives cross-validation estimates of misclassication error (xerror), ...
6
votes
1answer
461 views

CART (rpart) balanced vs. unbalanced dataset

I am fitting a tree (CART) to the olives-dataset. The training data has 436 observations (test data: 136). I have 3 responses (the 'Region' variable) which splits the training data into 116 / 74 / 246 ...
1
vote
0answers
357 views

decision tree using user defined split function in rpart: No splits returned when tree is run

I've written a user defined splitting function to use with rpart, its returning a 'vector of goodness', but the tree that is returned never has any splits, just one node. using the anova method on ...
9
votes
2answers
2k views

party vs. rpart vs. ??? for partitioning trees in R

It's been a while since I looked at partitioning trees. Last time I did this sort of thing, I like party in R (created by Hothorn). The idea of conditional inference via sampling makes sense to me. ...
4
votes
1answer
713 views

Difference in implementation of binary splits in decision trees

I am curious about the practical implementation of a binary split in a decision tree - as it relates to levels of a categorical predictor $X{j}$. Specifically, I often will utilize some sort of ...
3
votes
1answer
680 views

Overcoming memory constraints in rpart?

I have 4.4 million observations, 160 binary features, and a binary response. Using rpart on Windows (64-bit, with the 64-bit R v2.13.0 build), I run out of memory on a machine with 64GB RAM. My memory ...
5
votes
3answers
355 views

Recursive partitioning using median (instead of mean)

As I am only familiar with the basics regarding decision trees I would like to ask, with the risk of stating silly question: Is it possible to perform recursive partitioning with the group median as ...
2
votes
1answer
1k views

How to choose the number of splits in rpart()?

I have used rpart.control for minsplit=2, and got the following results from rpart() ...
1
vote
2answers
2k views

Recursive partitioning using rpart() method in R

I am new to R and using rpart for building a regression tree for my data.I wanted to use all the input variables for building the tree, but the rpart method using ...
3
votes
1answer
835 views

Organizing a classification tree (in rpart) into a set of rules?

Is there a way that once a complex classification tree is constructed using rpart (in R), to organize the decision rules produced for each class? So instead of getting one huge tree, we get a set of ...
3
votes
1answer
159 views

How to produce a CI for a value predicted in CART?

My goal is to create CI for the CART prediction of new_x Consider the following code: ...
13
votes
3answers
11k views

What is Deviance? (specifically in CART/rpart)

What is "Deviance," how is it calculated, and what are its uses in different fields in statistics? In particular, I'm personally interested in its uses in CART (and its implementation in rpart in R). ...
9
votes
2answers
4k views

How to measure/rank “variable importance” when using CART? (specifically using {rpart} from R)

When building a CART model (specifically classification tree) using rpart (in R), it is often interesting to know what is the importance of the various variables introduced to the model. Thus, my ...
3
votes
1answer
765 views

R-square from rpart model

How can I extract the R-square from a fit rpart model? rsq.rpart(fit) plots the two graphs, but I simply want to extract the R-square value for the full tree. ...
3
votes
1answer
549 views

Estimate the “meaningful” predictors for a value in a CART model (rpart)

When building a CART model (specifically classification tree) using rpart (in R), it is sometimes obvious that there are variables (X's) that are meaningful for predicting some of the outcome (y) ...