Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
6 views

Why different seeds produce different mse values for regression tree and ols?

I compare regression tree and ols in terms of out of sample prediction. I realized that the mse values changed when i change the seeds before getting train and test set. Sometimes ols is better ...
0
votes
1answer
21 views

When does OLS Regression outperform regression tree in term of out of sample prediction?

In my Master thesis i compare ols regression to regression tree to predict wages. I thought that i will get better prediction with the regression tree because it cathes more interactions. But now i ...
0
votes
0answers
11 views

Calculating precision and recall performance metrics in a classification tree analysis in R

I'm posting here as I suppose the topic of my question is more relevant for this forum, although please let me know if I'm wrong. I'm reformulating a previous question I posted in the R forum with ...
0
votes
0answers
47 views

Understanding a Classification Tree applied to the iris dataset

I used the iris dataset for a simple regression tree to see how things work. I am generally interested in two aspects: Why does the tree not use the Sepal data to improve the classification What do ...
1
vote
0answers
61 views

Rpart and subsets

I am getting unexpected results from an rpart model, where the model selects two variables, one of which is a subset of the other. This in itself is not unexpected, but the seemingly odd thing is that ...
1
vote
0answers
58 views

Why do RMSE values increase on a smaller tree (RPART)

AIM: I want to understand why does RMSE increase on a smaller tree. CONTEXT: I am learning the rpart algorithm. I had some data,...
0
votes
0answers
330 views

Metrics in rpart decision trees

I am currently working with decision trees in R, I am using caret library. Source code of rpart can be found here: https://github.com/cran/rpart/blob/master/R/rpart.R I understand how decision trees ...
0
votes
0answers
34 views

Do you know the explicit formula for Rel error in rpart?

Here is my investigation: Someone says I should not ask this in stackoverflow which is focused on programming and coding problem, and this is conceptual problem In some post, I do find an answer, ...
0
votes
2answers
118 views

classification tree with rpart()

I'm using the rpart() to build a classification tree using R. I have no experience in this topic... Anyway, I started with the full model, and then I used the varImp() from "caret" to drop some ...
1
vote
0answers
74 views

Performance of Conditional Inference regression Trees updating the influence function at each node

My goal is to compare the performance of $2$ models of trees using the Conditional Inference tree framework described in (ctree: Conditional Inference Trees), I am following the Partykit 2018. ...
0
votes
0answers
50 views

Test statistics used for a conditional inference multivariate regression tree?

The information provided related to the question "Test statistics used for a conditional inference regression tree?" proved to be quite useful (Test statistics used for a conditional inference ...
1
vote
1answer
170 views

Test statistics used for a conditional inference regression tree?

Following the question asked previously about the interpretation of the Test Statistic used for Conditional Inference Trees (What is the test statistics used for a conditional inference regression ...
2
votes
0answers
40 views

Is rpart randomizing the variables it tries as splits?

I am fitting a decision with rpart on R. I have many variables and it seems to me that it would take a long time for rpart to try them all at every step, to determine what the next best split is. ...
2
votes
1answer
537 views

Are decision trees sensitive to log translations in feature space?

This question was partially answered on Are decision trees sensitive to translations in feature space?, but no references were provided for "Gini impurity and entropy measures are translation ...
1
vote
0answers
11k views

Interpretation of Rpart for Decision Trees

I recently used rpart for an R-decision tree, but am confused on how to read the results.... ...
2
votes
0answers
3k views

Decision Tree in R: rpart on categorical variables

Introduction: I would like to build a classifier which distinguishes between buyers and non-buyers based on user behavior. This data is highly imbalanced (0.009% for positive class), and I'm ...
1
vote
1answer
42 views

Classification in R - seperate category for uncertain classifications

I am constructing classification trees for the first time, so I'm quite new to this use of R. I have observations of behaviours and incoming data that has to be classified as one of these behaviours. ...
0
votes
0answers
748 views

discretization to create intervals for continuous variables

I am new to R and have basic stats understanding. Please excuse me if my questions are basic in nature. I am learning and having these questions and your answers would help me in updating my knowledge....
1
vote
1answer
404 views

Use decision tree to learn precise classification rules: need accuracy of 1

I'm trying to use a decision tree algorithm to learn how general ledger transactions (10 digit code) are classified into revenue, expense, G&A et cetera without actually scripting every ...
1
vote
0answers
830 views

how to interpret value.importance for an rpart object

How can I interpret the values for the variable.importance in a rpart object? ...
1
vote
1answer
519 views

How can I use estimated probabilities of a class from rpart to identify the top N classes?

Using the rpart library, I'm trying to predict which class each observation belongs to. Here is a reproducible example explaining the steps I am taking: ...
4
votes
1answer
228 views

Disrepencies between Information Gain and Tree Growth

I was wondering if someone can explain to me why in my decision tree some of the variable with the highest importance (highest information - script shown below) do not appear into my tree at all, ...
0
votes
1answer
52 views

What does a decision tree with both GOOD outcome means?

I have a decision tree built in R using rpart() from rpart package. However, when following the nodes, we have one condition leading to both outcomes as GOOD. This is weird for me. What does that ...
2
votes
1answer
459 views

Handle missing value in continuous variable in Decision Tree without losing its meaning

I want to train a Decision Tree model with a dataset, of which some of the continuous variables contain missing values. I want to preserve the meaning of missing value while training, meaning that ...
1
vote
1answer
278 views

Understanding rpart package - unexpected behavior when swaping two columns in explanatory varaibles table

I have a problem understanding the behavior of rpart function of R. Here is the r code part : ...
0
votes
1answer
666 views

Loss matrix to be included in decision tree? Rpart -R

For loss matrix, is it necessary to include it during the decision tree analysis ? What will be the impact if this is excluded from the analysis e.g loss matrix (0,1,1,0) in Rpart-R? Do we usually ...
0
votes
1answer
73 views

Continuous output instead of classification

I was trying to do some classification problem where target variable should be one of 4 classes. I tried rpart and ranger ...
1
vote
0answers
98 views

Classification tree cross val error increasing but test error decreasing

My data has 5000 points. I predict a categorical outcome using 10 numeric variables. I build a tree with 3500 points (in R using rpart) using cross validation and plotcp shows this below ... I have ...
0
votes
1answer
498 views

Use of regression-trees to determine probabilities for a binary variable

I have a binary variable (sold/not sold) and I have used the CART algorithm in R (rpart) to build a classification tree to predict if this product is getting sold or not. Now I would like to add a ...
5
votes
1answer
9k views

rpart, Cross Validation. [closed]

I have a question of using the rpart for the regression tree. I am wondering when i use plotcp, where would my validation data comes from? Currently, I have a ...
0
votes
0answers
822 views

What is the formula of varImp in R?

I'm using varImp function(caret package) in R to get importance of variables and to select variables. I know how can i get result. This is my code and result. ...
1
vote
1answer
302 views

Rpart regression tree using aggregate data instead of record level data – The results are not the same

I have a large dataset (over 6 million records) and I have aggregated the dataset (dplyer package) and tested rpart() on the two ...
1
vote
1answer
735 views

Decision tree with imbalanced data not affected by pruning

I am looking to use a Decision Tree to classify whether or not a car will sell based on attributes of that car. The attributes that I have include price, year, mileage, condition (new, pre-owned, or ...
0
votes
0answers
197 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
1k views

R, rpart(), classification tree, cptable$xerror

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 ...
1
vote
1answer
715 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
66 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
497 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
2k 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 ...
2
votes
1answer
680 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
121 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 ...
3
votes
2answers
8k 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
963 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 ...
5
votes
1answer
4k 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
361 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
43 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
334 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
699 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
60 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 ...