3
votes

When I typed the command for importance as below importance (model.rf) I get this error:

Error in UseMethod("importance") : no applicable method for 'importance' applied to an object of class "c('randomForest.formula', 'randomForest')"

How to solve this error?

1
Did you try restarting your R session? It's possible you're masking the randomForest importance(). Try randomForest::importance(model.rf) - Megatron
You need to provide a minimal reproducible example so we can see what you are really doing and what objects are involved. - MrFlick
Thank you it was helpful. - kruthika

1 Answers

0
votes
output.forest <- randomForest(nativeSpeaker ~ age + shoeSize + score,  data = 
readingSkills,importance=TRUE)
#You can use like this - Solution
out.importance <- round(importance(output.forest), 2)
print(out.importance )

first convert importance to variable and then print that out.