Questions tagged [rpart]

An R package for fitting classification and regression trees.

rpart is an package for fitting and trees ().

Repositories

Vignettes

Other resources

Related tags

445 questions
1
vote
1 answer

How to get sample split probability values from tree-based models - esp via the h2o framework

Following the proposed tree interpreter approach (http://blog.datadive.net/interpreting-random-forests/) one can explain a tree-based model prediction using info from the decision path. I've built tree models with H2o and exported them as PMML to do…
kevin5jan
  • 31
  • 1
1
vote
2 answers

Transform dummy matrix into label vector

I'm trying to create a confusion matrix, in order to build it I need to convert this matrix of predictions from my model into a label vector. (to compare it with the vector of actual labels) Matrix: Africa America CentralAsiaSiberia EastAsia…
dabadav
  • 25
  • 4
1
vote
0 answers

Error with rpart function in R: Error in terms.formula(formula, data = data) : duplicated name 'X.' in data frame using '.'

I was running some classification models for twitter sentiment analysis and I came across this error when using the rpart function: Error in terms.formula(formula, data = data) : duplicated name 'X.' in data frame using '.' Hope someone could help…
masuzo
  • 11
  • 2
1
vote
1 answer

How to change tree object class or plot nicely trees

I need to plot a nice tree for a project. The problem is that I have to use a specific function to create the tree that creates a tree datatype and all the functions used to plot trees in a nice way (ggtree, rpart.plot) require other types of…
1
vote
1 answer

Error message in R: error `[.data.frame`(m, labs) : undefined columns selected

I'm trying to run a regression tree in a dataset using the Train function. The dataset has numeric variables that I transformed to categorial trying to solve the error message. I'm also using the TrainControl function, again, to try to solve the…
1
vote
1 answer

How to get the original cp values from rpart object

My aim is to prune a deep tree according to a certain value of the cost-complexity parameter, say 3. I like growing trees with rpart(), in particular for the possibility of customizing plots. However, the cost-complexity parameter cp is rescaled to…
riccardo-df
  • 512
  • 4
  • 9
1
vote
1 answer

Is it possible to "Mirror" the look of a decision tree generated with rpart.plot in R?

I have generated a simple decision with rpart and displayed it with rpart.plot like the following. Is it possible to edit the look of the tree so it's "mirrored" like the following: (e-100%) ____(yes)___|___(no)____ | …
Mert Onur
  • 129
  • 1
  • 8
1
vote
0 answers

decision trees using R, rpart, fragile families

So, I am utilizing the fragile families challenge for my dataset to see which individual and family level predictors predict adolescent academic performance (measured by GPA). Information about my dataset: FFCWS is a longitudinal panel study in…
1
vote
1 answer

How to choose the root node in Rpart package in R

I am working in a project which requires to use Rpart package in R to build a decision tree. However, my direct report manager is interested in a specific variables to start as the root node in the tree as he value that specific variable as…
Jason
  • 9
  • 3
1
vote
1 answer

Change formatting for branch names in rpart plot

When using rpart to create and plot trees there are a number of functions which can alter the final appearance, however it appears nothing built in which allows for formatting the branch names. Below is an example of (A) what happens normally, and…
Beavis
  • 476
  • 3
  • 13
1
vote
0 answers

Can you specify decision tree splits to manually "replicate" trees?

I have three datasets with overlapping predictor and outcome variables. I would like to take the tree (e.g., same predictor variables and splits) I created in dataset 1 with rpart and apply it to datasets 2 and 3. Is this possible to do?
Frank
  • 11
  • 2
1
vote
1 answer

rpart summary: missing variables in plot

I have a dataset with 9 features, from x1 to x9. Target variable is Target (I have a classification problem). The code: # Splitting the dataset into the Training set and Test set # install.packages('caTools') library(caTools) set.seed(123) split =…
Mark
  • 1,577
  • 16
  • 43
1
vote
2 answers

Error in UseMethod("accuracy") : no applicable method for 'accuracy' applied to an object of class "c('double', 'numeric')"

i was trying to predict price for used car data in r. i have done all the preprocessing and divided the data into training and test set. here i am using regression tree. when i was trying to get accuracy i got this…
rishi
  • 13
  • 1
  • 6
1
vote
3 answers

RPART model ignoring variable while fitting the model

When I am trying to fit a classification tree model using Survival~Sex+Pclass , it is not considering the Pclass and is only considering sex (when Survival, Sex, and Pclass are factored as shown in the code)no matter what the control parameter is…
1
vote
1 answer

Re-structure the split labels at the end of each leaf in rpart

I am currently working with rpart.plot() to plot a decision tree (like the one attached in the picture). My concern is whether I can split the line, containing the levels of the decision choice below each leaf, in two lines? In this way the…
vog
  • 770
  • 5
  • 11