I am facing a very confusing problem while using the caret package in R. For a comparison, I am training multiple models. After a few calls to train, this error message begins to show for which ever train call / train model I use:-
Error in UseMethod("train") : no applicable method for 'train' applied to an object of class "formula"
Once this error appears, no other model is trained but the above error appears instead.
When I restart R and load the caret package again, the same models for which this error appeared, get trained easily.
I am confused as to what seems to be the issue here?
I have made a function for the 5 training models I try to create:-
test = function(){
a = train(demand ~ temp, oldData, 'lm')
print("Done A")
b = train(demand ~ temp, oldData, 'rf', ntree = 10)
print("Done B")
c = train(demand ~ temp, data = oldData, method = "gbm",
trControl = objControl, tuneGrid = gbmGrid, verbose = F)
print("Done C")
d = train(demand ~ temp, oldData, 'mlp')
print("Done D")
e = train(demand ~ temp, oldData, 'monmlp')
print("Done E")
}
P.S: Although, I have trained all these models successfully, I am trying to create an ensemble function for which I intend to run all these calls together.