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
0
votes
1 answer

How do specify different class priors while using caret package?

In R, rpart function allows me to set different class priors through 'parms'. How do I set this while using the train function in caret?
KTY
  • 709
  • 1
  • 9
  • 17
0
votes
1 answer

Top n classes of leaf nodes from decision tree

I'm using rpart pacakge of R and I want to extract the top 2 predicted classes for the leaf node instead of just the best. Take iris data as an example: fit <- rpart(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, data =…
Bamqf
  • 3,382
  • 8
  • 33
  • 47
0
votes
0 answers

Automate computing resubstitution error from printcp output result

I have an output for my printcp but I don't know how to call certain variables from it. For example: data(iris) library(caret) idx <- createDataPartition(iris$Species,list=FALSE, p = .67,times = 1) IrisTrain <- iris[ idx,] IrisTest <-…
hope288
  • 725
  • 12
  • 23
0
votes
1 answer

Bagging in R: How to use train with the bag function

In R, I am trying to use the bag function with the train function. I start with using train and rpart for a classification tree model, on the simple iris data set. Now I want to create a bag of such 10 trees with the bag function. The documentation…
0
votes
1 answer

How to set a minimum depth in tree in rpart? / Rpart tree using only one observation

I'm working on a project and I need to make a decision tree based on a dataset I've imported into R. The dataset contains 155 observations and 24 attributes + class. I created a tree using the rpart package. However, the tree came out very simple,…
0
votes
1 answer

Rpart - accuracy of bigrams

Good evening, everyone! I am facing a problem in R. I have a dataset containing Amazon reviews of the Playstation 4 and I would like to create a prediction model with the help of rpart and also would like to have the accuracy of this model. The…
Paul
  • 13
  • 6
0
votes
1 answer

How to make an arbitrary large number of variables be treated as factors

I have a large amount of variables that I must treat as categorical although they are represented numerically. For one variable I know I can use train$var1 = as.factor(train$var1) But how can I apply the same for as many variables as I want?
LetsPlayYahtzee
  • 7,161
  • 12
  • 41
  • 65
0
votes
1 answer

Decision Tree in R with binary and continuous input

we are modelling a decision tree using both continous and binary inputs. We are analyzing weather effects on biking behavior. A linear regression suggests that "rain" has a huge impact on bike counts. Our rain variable is binary showing hourly…
Bukowski
  • 53
  • 1
  • 7
0
votes
1 answer

how can i make a tree by using rpart in r

i am new to R and rpart. i don't know why can i make tree. here is my code and result library(rpart) library(partykit) onp.tr <- rpart(rshares~., reonp) onp.tr > onp.tr n= 39644 node), split, n, loss, yval, (yprob) * denotes terminal…
김주형
  • 1
  • 1
0
votes
1 answer

Review star rating - prediction in R

I have a dataset of reviews that have the following structure: { "reviewerID": "XXXX", "asin": "12345XXX", "reviewerName": "Paul", "helpful": [2, 5], "reviewText": "Nice product, works as it should.", "overall": 5.0, "summary": "Nice…
Paul
  • 13
  • 6
0
votes
1 answer

R caret package (rpart)

I get the below error when using rpart library dt <- rpart(formula, method="class", data=full.df.allAttr.train); Error in model.frame.default(formula = formula, data = full.df.allAttr.train, : object is not a matrix When i convert…
user2478236
  • 691
  • 12
  • 32
0
votes
1 answer

Pruning rpart tree

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 plotcp function. When I use printcp to analyze the results of the cross validation, among other details, I get the…
Dataminer
  • 1,499
  • 3
  • 16
  • 21
0
votes
0 answers

change root node in rpart [r]

I am building a model to detect perturbances in a dataset using rpart. below is a simple code: model1 = rpart(OA~I0+IA,data=data,method="class",control = rpart.control(minsplit = 20, minbucket=1)) The resultant is a tree with "I0" as root node. …
0
votes
2 answers

What does the numbers inside a node in fancyRpartPlot() mean when using method="anova"?

I'm new to the decision tree world and I've been trying to understand what the numbers inside the nodes of this fancyRpartPlot() image means. Below there's the code and the plot. cfit2 <- rpart(pgstat ~ age + eet + g2 + grade + gleason + ploidy,…
Oracle
  • 11
  • 1
  • 4
0
votes
0 answers

Can rpart be applied on mixed data set in R?

I have a dataset with both categorical and numeric attributes. Also, 17% of the data contains missing values. I want to apply decision trees on it. Can rpart function from rpart library in R be applied? is there any alternative package which can…
areddy
  • 373
  • 3
  • 7
  • 18