`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
7 views

Plotcp Plot Plateaus

I'm trying to understand why this graph plateaus. I have many more levels in the predictors than there are splits, so I'm confused why the tree stops splitting at only 447. I'm also confused why the ...
0
votes
1answer
30 views

Is the rpart CART algorithm deterministic? Why are the plots for the CP different?

I'm fitting regression and classification trees. I thought that the algorithm to fit the tree led to the same result each time. However, when I run the line below ...
1
vote
0answers
19 views

Non-recursive regression tree

I would like to construct a regression tree such that each factor appears at most once on each branch. When I use rpart in R, it commonly results in a tree where ...
0
votes
0answers
13 views

Regression trees to model rates

I am performing a predictive modeling application where I have to predict claims. If I had used classical GLMs, I would have used a poisson glm using log exposure as offset, assuming therefore ...
0
votes
1answer
37 views

Extract training data predictions from rpart

I'm wondering if there is any method to extract the class assignment of each sample in an rpart model from the training data? E.g. in R using random forest to get the predicted class of each sample ...
0
votes
0answers
51 views

Accuracy of rpart for categorical

Below is an example of fitting categorical data using rpart. But how to compare the predictions from rpart with the actual data? Also, is it possible to draw a ROC curve for the testing and training ...
1
vote
0answers
60 views

How to Force Split Decision Tree in R

Is there any ways that a user can force split the decision tree in R ? I just think when building decision tree, we may need expert judgement in order to obtain the final model. As far as I know, ...
1
vote
1answer
138 views

Understanding RPART model results

I have operational fault data and maintenance data. The operational fault data was used to determine if the maintenance improved the fault indicator (true/false). The maintenance data was used to ...
0
votes
0answers
14 views

Plotting Classification Tree with a lot of Factors - Legend Option?

I want to plot a classification tree and display it nicely. The problem is, because my factor variable has a lot of levels, the node displayed would look something like this: State Name = alabama, ...
1
vote
1answer
27 views

The Strength of the Decision in Decision Tree

I learn how to use decision tree in R library(rpart) fit <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis) asRules(fit) return, ...
0
votes
1answer
71 views

How to choose an appropriate maxdepth in rpart.conrol?

I'm using the boosting method in adabag library and trying to choose an appropriate maxdepth in rpart.control for building a 2-class classification model using my training dataset. I have noticed that ...
0
votes
1answer
220 views

Interpreting rpart output for decision trees?

How do I go about selecting the ideal location to use for pruning the tree here? Or maybe someone can explain to me in simple language what this output means. I see that rel_error is constantly ...
0
votes
1answer
106 views

Rpart using Caret changes names of Factors

If I have a factor e.g. sexe with two levels MALE and FEMELLE let's say, using rpart alone I get splits that say for example Sexe = Male and then a yes no split. However using rpart with caret I get a ...
5
votes
2answers
179 views

How to evaluate the goodness of fit for survial functions

I am a newcomer to survival analysis, although I have some knowledge in classification and regression. For regression, we have MSE and R square statistics. But how we can say that survival model A ...
0
votes
0answers
26 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
108 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
2answers
723 views

rpart complexity parameter confusion

I'm a little bit confused on the calculation for CP in the summary of an rpart object. Take this example ...
1
vote
0answers
173 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 ...
1
vote
0answers
60 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 ...
1
vote
1answer
334 views

Difference between rel error and xerror in rpart regression trees

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
30 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
447 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 ...
2
votes
2answers
519 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
85 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
83 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
559 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
230 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
81 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
857 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
514 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
1answer
138 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
136 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
3k 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
89 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
193 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
65 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
551 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
301 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 ...
6
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 ...
3
votes
0answers
417 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
159 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
3k 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
525 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
439 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
3k 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. ...
5
votes
1answer
975 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
792 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
398 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
2k 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
3k 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 ...