`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

1
vote
0answers
14 views

When using loss matrix in rpart in R, xerror does not start at 1 [closed]

I am trying to use a loss matrix in rpart penalizing false positives 10 times as much as false negatives, but when I fit my data and then use printcp, my xerror values start at 10 and not 1. I am ...
1
vote
1answer
47 views

Decision Tree Interpretation (Classification using rpart)

When using rpart to create classification tree, the values for the relative importance of each predictor show up along these lines: ...
0
votes
1answer
48 views

Why does ctree(partykit) perform worse than rpart for a large dataset?

I am trying to solve the same classification problem with the R packages rpart and partykit. I would have expected better ...
4
votes
1answer
128 views

How does the complexity parameter correspond to the number of splits in cross validation in rpart?

library(rpart) tree = rpart(Kyphosis ~ ., data=kyphosis, control=rpart.control(minsplit = 1, cp = 0, xval=10)) plotcp(tree, minline = FALSE, upper=c("splits")) ...
0
votes
0answers
60 views

Lack of fit for decision trees

I am using the cp argument in the rpart function in R. I would like to understand exactly how lack-of-fit is calculated for decision trees. Please provide a simple example if possible. Thanks. ...
2
votes
0answers
56 views

How exactly is the cost-complexity parameter in rpart selected?

I read the description of rpart and some other sources about classification trees. Still, I'm not sure if I completely understood how rpart selects these parameters. I would appreciate it if someone ...
1
vote
0answers
22 views

Is minimised cross-validated error equivalent to maximised cross-validated accuracy?

I'm running a classification tree using the function rpart. Usually, I choose the tree that minimises the cross-validation error. I was wondering, since error-rate is normally defined as 1-Accuracy. ...
0
votes
0answers
47 views

Why is there a difference between using the package rpart and using the method “rpart” in the caret package?

When I'm running rpart on my train set, it suggests a different cp than rpart does, even though I'm using the same seed. The two formulas I am using are: Using the Caret package fitControl <- ...
1
vote
0answers
51 views

How to find the optimal cp value in rpart doing cross validation manually?

I'd like to test two classifiers at the same time, that is logistic regression and classification trees. To find a classification threshold, which for example maximises F1-score, I split my data set ...
2
votes
0answers
125 views

Is using Rpart with unbalanced data a good idea?

I have a rather unbalanced data set and want to use rpart to build a classification tree. After building the full tree, I prune it back using the 1-SE rule. On average, only 1-2 splits are suggested. ...
2
votes
0answers
25 views

Consistent way of calculating average tree size using repeated cross validation?

I'd like to examine the behaviour of my classifier concerning the tree size. That is, I'm using rpart to build and prune the tree. For the rest of my analysis I'm running repeated 10 Fold Cross ...
0
votes
0answers
36 views

How can I rank the coefficient's contribution/importance for logistic regression?

My situation is the following; I'm running a classification tree (with the function rpart in R) and a logistic regression on a data set using 10 Fold cross-validation. Since I'm estimating the model ...
0
votes
0answers
35 views

Root node error in rpart

Can anyone provide the equation for "root node error" in rpart? I have a training data sample with 120 rows. Half of the training sample is classified as ...
0
votes
1answer
125 views

How can I forecast a time series using Cart models?

I'm using the rpart library to try forecasting the electricity consumption from Australia (example from the book Introductory Time Series with R): ...
0
votes
0answers
80 views

How cross validation error increases in CART while relative error decreases?

I am using a simulation dataset with rpart as follow: ...
0
votes
0answers
24 views

Randomize and give priority

I built one interesting model in R. This model is based on rpart library. The way I use this library is following (it may be ...
0
votes
0answers
67 views

Pruning an rpart tree

I've never played with the rpart package so I'm trying to get myself oriented. I followed the example from the docs and then tried to replicate it myself with my ...
0
votes
0answers
38 views

grow a regression tree one split at a time

I'm growing a regression tree with the rpart function in R (package of the same name). I would like to be able to choose myself the number of nodes (not the depth ...
0
votes
0answers
42 views

What does it mean when Root node error is greater than 1?

Using rpart, I see the error metrics with printcp(tree). I understand these metrics according to this answer. What does it mean when Root node error is greater than ...
2
votes
0answers
13 views

pruning : why if T1 and T2 (2 subtrees) with the same risk imply that one must be a subree of the other

I don't understand the following assertion from "An Introduction to Recursive Partitioning" page 13. If T1 and T2 are sub trees of T with Rα(T1) = Rα(T2), then either T1 is a sub tree of T2 or ...
0
votes
1answer
166 views

Plotcp in rpart package

I am trying to create a decision tree using the rpart package in R. To arrive at the optimal depth for the tree, I am using the ...
2
votes
1answer
896 views

Decision Trees rpart R categorical and continuous variables

I run some decision trees in rpart with 10 continuous variables and 3 categorical variables (with 1 or 0 options), the result of the tree was that none of the 3 ...
0
votes
0answers
30 views

Drawing tangible insights from rpart model splits

I'm working on a data set for an engineering problem which involves the use of pumps. My main objective is figuring out how to reduce the number of pumps used where the maximum number of pumps is 4 ...
0
votes
1answer
65 views

Why is CART in R not using my factor variables?

I have data which looks like ...
2
votes
1answer
113 views

CART with Ordinal Response Variable using rpartScore Stuck

I'm trying to fit a decision tree over some data which has ~40K rows and ~200 features. The response variable, y, is ordinal and takes values ...
0
votes
2answers
183 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
699 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
137 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
86 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
214 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
109 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
379 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
254 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, ...
2
votes
2answers
218 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
108 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
120 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
98 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
242 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 ...
2
votes
2answers
132 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
49 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 ...
2
votes
1answer
227 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 ...
2
votes
1answer
289 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 ...
2
votes
0answers
198 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
631 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 ...
1
vote
1answer
96 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
2k 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 ...
1
vote
1answer
434 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
624 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 ...
3
votes
0answers
189 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 ...
2
votes
2answers
6k 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 ...