Reputation: 2239
It seems that in R, if we fit a randomForest and try to figure out importance, we get different results depending on if we use $importance or the function importance for %IncMSE. Not sure why?
> rf.model = randomForest(Weight ~ ., data = XYWeightTrain, importance = TRUE, ntree = 500, xtest = XYWeightTest[, -1], ytest = XYWeightTest[, 1])
> rf.model$importance
%IncMSE IncNodePurity
Wrist.Diam 0.8212594 305.3484
Wrist.Girth 2.8674595 1244.2349
Forearm.Girth 14.7491374 6681.7611
Elbow.Diam 1.0207908 427.8362
Bicep.Girth 7.9351242 4636.7848
Shoulder.Girth 9.5574023 5108.2292
Biacromial.Diam 0.9785278 347.9064
Chest.Depth 2.0081676 873.7349
Chest.Diam 1.9936859 1330.1593
Chest.Girth 24.2663570 9815.0322
Navel.Girth 2.1440752 648.8285
Waist.Girth 31.6001879 12512.4992
Pelvic.Breadth 0.5893632 227.1361
Bitrochanteric.Diam 1.1661954 346.4844
Hip.Girth 8.0548212 2178.3831
Thigh.Girth 2.8990134 726.3200
Knee.Diam 3.6684350 1207.6730
Knee.Girth 6.3831885 2258.2849
Calf.Girth 5.6392469 1972.3754
Ankle.Diam 0.7002560 199.7919
Ankle.Girth 2.0712253 684.4244
> importance(rf.model)
%IncMSE IncNodePurity
Wrist.Diam 7.541535 305.3484
Wrist.Girth 9.240727 1244.2349
Forearm.Girth 12.534953 6681.7611
Elbow.Diam 8.742194 427.8362
Bicep.Girth 9.966211 4636.7848
Shoulder.Girth 11.263877 5108.2292
Biacromial.Diam 6.680291 347.9064
Chest.Depth 10.196696 873.7349
Chest.Diam 6.846195 1330.1593
Chest.Girth 15.979216 9815.0322
Navel.Girth 12.194066 648.8285
Waist.Girth 20.320096 12512.4992
Pelvic.Breadth 6.575887 227.1361
Bitrochanteric.Diam 9.568542 346.4844
Hip.Girth 20.481270 2178.3831
Thigh.Girth 15.100160 726.3200
Knee.Diam 16.784600 1207.6730
Knee.Girth 19.353398 2258.2849
Calf.Girth 18.927534 1972.3754
Ankle.Diam 6.360296 199.7919
Ankle.Girth 9.868660 684.4244
Upvotes: 2
Views: 1906
Reputation: 2397
If you just print the importance object from the model they are the raw importance values. However, when you use the importance function, the default for the scale argument is TRUE which returns the importance values divided by the standard error. If you use importance(rf.model scale=FALSE)
the values should be the same.
I would highly recommend using the %IncMSE and not the GINI (IncNodePurity). The %IncMSE is permuted, at the nodes, and is a more stable representation of variable importance.
Upvotes: 4