Variable Importance - caret and filterVarImp has quirks not documented?

Hard coded variable Overall is causing unusual popup of view window.
Hard coded variable Overall does not like to be a sort variable or renamed.
How to fix?

library(caret)
cat("\n","Variable Importance")

names(df2)
one<- df2[,c(3:14)]
names(one)
two <- df2[,15]
two

temp <- filterVarImp(one,two)
class(temp) #data.frame
str(temp)   #12 numeric observations of 1 variable called Overall

feature <-  row.names(temp)  #12 alphanumeric observations z x1 x2 ... x11
Overall <- temp$Overall

temp2 <- cbind(feature,Overall) #VIEW WINDOW POPS UP HERE. STOP HOW??????????
temp2 <- as.data.frame(temp2)
str(temp2)  # 12 obs. of  2 variables (feature,Overall)

#this code does not sort by temp2$Overall  WHY???????????????????????????????
temp3 <- temp2[order(temp2$Overall, decreasing = TRUE),] 
str(temp3)
print(temp3)

#this code does sort by Overall (gotten from working memory)
temp4 <- temp2[order(Overall, decreasing = TRUE),] 
str(temp4)
print(temp4)
names(temp4)
names(temp4)[2] <- "importance"
names(temp4)
print(temp4)

Solution is to create a data frame importance.df using data.frame function.
Popups have stopped.

# Variable Importance -with caret and function filterVarImp
df2 <- read.csv(file="df2.csv",header=TRUE,sep=",")
predictor.df<- df2[,c(3:14)]
outcomes <- df2[,15]
library(caret)
temp <- filterVarImp( predictor.df, outcomes )
importance.df <- data.frame(features = row.names(temp), importance = temp$Overall)
importance.df <- importance.df[order(-importance.df$importance),] 
print(importance.df)

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.