Decision Tree in R rpart() variable importance

#1

Hello
I was able to get variable importance using iris data in R, using below code

tree=rpart(setosa_dummy~.,data=data,method="class")
tree$variable.importance

But when I tried the same with other data I have. tree$variable.importance returns NULL. Any specific reason for that. I was getting NaN for variable importance using "rf" method in caret. varImp() was used.

0 Likes

#2

Can you please provide a minimal reprex (reproducible example)? The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it: please help me help you!

If you've never heard of a reprex before, start by reading "What is a reprex", and follow the advice further down that page.

0 Likes

split this topic #3

A post was split to a new topic: tree$variable.importance returns NULL with rpart() decision tree

0 Likes