I have divided my data set into two groups:
- transactions.Train (80% of the data)
- transactions.test (20% of the data)
Then I built the decision tree using ctree method from party package as follow:
transactions.Tree <- ctree(dt_formula, data=transactions.train)
And I can successfully apply predict method on the training set and use table function to output the result as follow:
table(predict(transactions.Tree), transactions.train$Satisfaction)
But my problem occurs when I try to output the table based on the testing set as follow:
testPred <- predict(transactions.Tree, newdata=transactions.test)
table(testPred, transactions.test$Satisfaction)
And the error is as follow:
Error in table(predict(pred = svm.pred, transactions.Tree), transactions.test$Satisfaction) :
all arguments must have the same length
I have done research on similar cases which suggested omitting any NA values which I did without changing the error outcome.
Can anyone help me by poniting out what's the problem here?