nrainer
nrainer

Reputation: 2623

Error: "Not compatible with requested type" when plotting varImp

When training a model in R with the caret package, I get an error when plotting variable importances of the model. This happens for several mining algorithms (bayesglm, glm, naive_bayes, ...).

control <- trainControl(method = "repeatedcv",
                      number = iterations,
                      savePredictions = TRUE,
                      classProbs = TRUE,
                      sampling = "smote");

modelFit <- train(formulaToUse,
                data = dataToAnalyze,
                method = miningAlgorithm, 
                family = "binomial", 
                preProcess = NULL, 
                trControl = control,
                tuneLength = 4);

plot(varImp(modelFit, scale = TRUE));

results in:

Error in auc_(actual, predicted, ranks) : 
Not compatible with requested type: [type=character; target=double].

Note that the models are mined with success, summary(modelFit) shows information about the model.

Any ideas?

R version is 3.4.3, caret is caret_6.0-79.

Upvotes: 4

Views: 13761

Answers (1)

nrainer
nrainer

Reputation: 2623

From the comments: The cause was that one parameter in the formula was based on the character values. The solution is to remove this parameter (or to map / convert it to another data type).

Upvotes: 1

Related Questions