`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
1answer
27 views

Setting different depth in rpart, but didn't actually change

I am tuning my decision tree with different depths. I wanted to see my results for trees with depth from 6 to 12. Instead of creating a loop, I am manually changing the parameter. My problem is, ...
1
vote
1answer
49 views

rpart classification: why is my predict() output not adhering to type=“class”?

I have a dataframe, 'datas', with 200 observations and a series of columns (some numeric, dummy, etc) and a binary class variable to be predicted that is called "bad_econ." I would like to get the ...
0
votes
0answers
19 views

Difference between weights and prior in rpart and how to use them

I have a question about the "weights" and "prior" in R's rpart function. This question has been asked before here, but the answer doesn't quite make sense. Currently I have very unbalanced data ...
0
votes
1answer
36 views

classification tree with R part

I am trying to grow a classification tree with a few continuous explanatory variables and a few factor variable. It seems the Rpart alogrithm is ignoring the factor variables. The differences are ...
1
vote
1answer
40 views

How to predict new data with a classification tree in R?

I have built a classification tree for factor variables with the rpart package and now I want to predict unseen data with it. How can I get a sense of whether the model is good at predicting unseen ...
0
votes
1answer
27 views

How do Conditional Inference Trees do binary classification?

I am trying to learn about Conditional Inference Trees, and have been doing some very simple comparisons of the ctree() and rpart() functions in R. I have looked at the documentation for ctree(), but ...
0
votes
1answer
65 views

Predictions for rpart model require more variables than shown in the classification tree

Using rpart from the caret package, when plotting the final model I get a classification tree that seems fairly simple (6 variables shown in tree). However, when I request the final variables from ...
0
votes
0answers
74 views

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, ...
0
votes
1answer
50 views

What is the equivalent of the complexity parameter ( rpart in R ) in python for regression trees (sklearn)?

The complexity parameter decides when to stop splitting. what is its equivalent in python. As decreasing the cp tends to increase the accuracy in the prediction, so is there a similar parameter in ...
0
votes
1answer
48 views

How to best sample for SVM and rpart in R's e1071 package?

I built a svm and a decision tree but I noticed that when I rerun the sample then the accuracy changes. This is obviously because the sample is changing every time. What is the best way to get the ...
0
votes
1answer
55 views

R: plot(tree) how to interpret the height?

Is there any signification in the height of the split in a tree when it's plotted with R ? Example: library(rpart) plot(tree) How can we interpret the fact than ...
1
vote
1answer
36 views

How to interpret concretely the misclassification error?

I'm reading about Cart classification with rpart on R, and after all we should compute the misclassification error, given that y is the column that stocks classes, and x is the variable columns and ...
0
votes
0answers
36 views

Meaning of the prior and loss parameters in rpart in R

Could someone please explain to me what specifying priors and/or loss parameters in R's rpart actually do? I found R's documentation completely unhelpful. For example, let's suppose I have a highly ...
1
vote
0answers
101 views

“Complete” classification using decision tree

While exploring the examples from "Practical Data Science with R", I am using a decision tree to classify the spambase dataset. It works fine, but I am trying to "abuse" the model in order to have ...
0
votes
0answers
36 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
70 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
32 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 ...
1
vote
1answer
89 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 ...
1
vote
1answer
110 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 ...
1
vote
0answers
103 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
287 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
27 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
58 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
183 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
583 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
250 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
271 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
33 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
135 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
2k 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 ...
2
votes
1answer
287 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
101 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
627 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
39 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
801 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
971 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
765 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
318 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
95 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
1k 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
851 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
181 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
147 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
5k 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
111 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
226 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
72 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
853 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
386 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 ...
7
votes
0answers
3k 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 ...