Closed fahadshery closed 4 years ago
I am new to ML so apologies in advance if I am doing something stupid :)
No worries!
Some things that might not have been obvious that I would try:
For train()
, using the formula interface will always create dummy variables. 99% of the time, that's no big deal but for models like trees, those functions generally don't create them.
Avoid using predict(caret_down_fit1$finalModel)
; use predict(caret_down_fit1)
instead. There are times that things are done to the data in train()
that the finalModel
object doesn't know about or can't recreate.
I think that this second point is the issue. train.formula
made your model using dummy variables (like the column TOT_CONTCT_FOR_COMPLNT_28Dbin1
) but the data frame test2
only has a column TOT_CONTCT_FOR_COMPLNT_28D
. Try using the predict function without specifying the finalModel
element.
Hi,
I successfully created an
rpart
model by:I want to do the same using
train()
but having various problems. Here is how I am trying to buildrpart
usingtrain
:This gives the following error:
However, this error goes away if I do:
Then it doesn't predict all the rows in test2:
Gives the following error:
Here is the data (Couldn't upload
.RData
file so saved it in.txt
format:test2.txt down_tree_new.txt
Session Info:
I am new to ML so apologies in advance if I am doing something stupid :)