i'm a bit newbie in R data mining algorithms and I need to develop a script that help me to predict an event. So, i've chosen a decision tree model to help with this task.
My dataset has this structure:
_____________________________
ATTR1 | ATTR2 | ATTR3 | CLASS
Y | N | N | N
______|______|_______ |_______
and this are the scripts that i've created:
library(party)
myFormula <- CLASS ~ ATTR1 + ATTR2 + ATTR3
ind <- sample(2, nrow(myData), replace=TRUE, prob = c(0.7,0.3))
trainData <- myData[ind==1,]
testData <- myData[ind==2,]
energy_ctree <- ctree(myFormula, data=trainData)
testpred <- predict(energy_ctree, newdata= testData)
all this commands work just fine. So, my doubt is about to predict new lines of data!
i've called the function predict(energy_ctree ,newdata=newdataSet) with new dataset excluding the CLASS columns (that I want to find through decision tree model prediction).
This is the error message i get:
"Error in checkData(oldData, RET) :
Levels in factors of new data do not match original data"
So, what are the steps to predict de Class column of my newDataSet based on the decisionTree model that i've created before.
Thanks in advance.
Carlos Lima