Questions tagged [rpart]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
406 views

How to make a regression model for a relation looking like a step function ? Why can't I get an output for recursive partitioning done below?

I'm working on a dataset to describe the relationship between length and age of bluegill fish and the linear model based plot looks like this: I hence tried using recursive partitioning algorithm as ...
2
votes
1answer
2k views

R, rpart(), classification tree, cptable$xerror [closed]

i randomly split my data into training and test sets. then using the training set, i construct an overfitting classification tree with 10-fold cross-validation. i.e. xval=10 and prune it (with ...
6
votes
1answer
1k views

Handling of categorical variables: rpart vs tree

For tree and randomForest packages in R, the number of levels for a factor (as a categorical variable) is capped at 32. An explanation might be that the number of comparisons at each split becomes ...
0
votes
0answers
170 views

how do you calculate the number of combinations recursive partitioning uses in decision trees?

So I was wondering why random forests limit the levels of a variable to 32 levels, and I found an answer here : R's randomForest can not handle more than 32 levels. What is workaround? My ...
0
votes
1answer
849 views

Predicting from RPart using a subset of variables

I fitted a RPart model from all of a couple dozen variables. Now, I want to test predictions using just a couple of variables that seem significant to me. If it was the iris dataset, for example, I ...
2
votes
1answer
3k views

How to improve my classification tree ? R

I have a database with 1200 observations and 14 variables and I'am trying to do a classification tree for my dependent nominal variable who hase 4 modality ...
3
votes
1answer
1k views

variable importance in boosted regression tree

I have trouble understanding how relative influence of a variable is calculated in a boosted regression tree. I am reading from the following paper by Friedman and Meulman. Multiple additive ...
1
vote
1answer
199 views

Minimizing Single-Class Classification Error in R Trees

I'm running tree models in R to help define rules for predicting a binary outcome (0 or 1, of course). I understand mostly how to algorithm works, but I'm in a position where I don't really care about ...
4
votes
3answers
14k views

Performance of regression tree rpart

I am running a regression tree using rpart and I would like to understand how well it is performing. I know that rpart has cross validation built in, so I should not divide the dataset before of the ...
1
vote
1answer
1k 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
1k 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 ...
6
votes
1answer
7k 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")) ...
2
votes
0answers
456 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
51 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. ...
1
vote
0answers
464 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
1k 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
63 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
1answer
782 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): ...
1
vote
0answers
458 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 ...
2
votes
0answers
31 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 ...
1
vote
1answer
2k 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 ...
7
votes
1answer
9k views

Why do Decision Trees/rpart prefer to choose continuous over categorical 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
1answer
908 views

Why is CART in R not using my factor variables?

I have data which looks like ...
3
votes
1answer
653 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
3answers
12k views

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

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, ...
2
votes
1answer
12k 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 ...
9
votes
1answer
7k 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
576 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
2answers
2k 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 ...
2
votes
1answer
1k 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
2k 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 ...
2
votes
2answers
5k 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
630 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
6k 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 ...
1
vote
0answers
2k 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
547 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 ...
7
votes
1answer
2k 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 $$\text{...
2
votes
1answer
2k views

Extract training data predictions from rpart [closed]

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
1k views

How to Force Split Decision Tree in R [closed]

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, <...
3
votes
1answer
7k 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 ...
2
votes
1answer
414 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, ...
1
vote
1answer
9k 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 ...
4
votes
1answer
2k 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 ...
10
votes
2answers
8k 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 ...
4
votes
0answers
837 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 ...
10
votes
4answers
43k 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 ...
9
votes
2answers
7k 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
775 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 ...
6
votes
2answers
9k 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 cross-...
1
vote
0answers
49 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 ...