Reputation: 1725
Im using the varImp function of the caret package and Im trying to plot the resulting dataframe that it creates. Here is the code:
RocImp2 <- varImp(svmFit, scale = FALSE)
and Im using a simple plot to plot the chart:
plot(RocImp2)
The results are supposed to look like this:
whereas mine looks like this:
Here is a copy of the dataframe:
disregard the names in the plot as they are from another example.
Upvotes: 2
Views: 9900
Reputation: 31
here is a solution to plot the varImp in the case of a binary classification model.
model = glm(Survived~.,family="binomial", data=Titanic)
V = caret::varImp(model)
ggplot2::ggplot(V, aes(x=reorder(rownames(V),Overall), y=Overall)) +
geom_point( color="blue", size=4, alpha=0.6)+
geom_segment( aes(x=rownames(V), xend=rownames(V), y=0, yend=Overall),
color='skyblue') +
xlab('Variable')+
ylab('Overall Importance')+
theme_light() +
coord_flip()
Upvotes: 3
Reputation: 111
My issue was fixed by adding the following.
ggplot2::ggplot(varImp())
Upvotes: 5
Reputation: 1
I found a workaround this problem. You could try:
write.csv(RocImp2, file = 'RocImp2.csv')
VIMP <- read.csv('RocImp2.csv')
plot(VIMP)
Upvotes: -1