Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Contrasts dropped from factor x in decision tree?

$
0
0

@cupcake wrote:

Hi,
I have faced this block for a few days even with much research online, and much grateful if there are some insights in dealing this kind of warnings: " Contrasts dropped from factor x" . This occurred when I tried to use newly created decision tree model to predict on the test data using rpart package.

Following are the scripts that I have used :
db$staffx.f<- as.factor(db$staffx)

contrasts(db$staffx.f) = contr.treatment(8) .... create same for other categorical variables.

tree<-rpart(L2 ~ staffx+....other variables, method = "class", data = db )

printcp(tree)

rpart.plot(tree,type = 3,tweak =1.2)

cpok<-tree$cptable[which.min(tree$cptable[,"xerror"]),"CP"]

tree.pruned<-prune(tree,cp=bestcp)

pred1 <- predict(tree,Testdata,type="class")

In which areas that I need to adjust ? Does this mean the model has failed?

Many thanks!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles