VarImp | R Documentation |
This is the extractor function for variable importance measures as produced by ODT
and ODRF
.
VarImp(obj, X = NULL, y = NULL, type = "permutation")
obj |
An object of class |
X |
An n by d numerical matrix (preferably) or data frame is used in the |
y |
A response vector of length n is used in the |
type |
specifying the type of importance measure. "impurity": mean decrease in node impurity, "permutation" (default): mean decrease in accuracy. |
A note from randomForest
package, here are the definitions of the variable importance measures.
The first measure is the total decrease in node impurities from splitting on the variable, averaged over all trees. For classification, the node impurity is measured by the Gini index. For regression, it is measured by residual sum of squares.
The second measure is computed from permuting OOB data: For each tree, the prediction error on the out-of-bag portion of the data is recorded. Then the same is done after permuting each predictor variable. The difference between the two are then averaged over all trees.
A matrix of importance measure, first column is the predictors and second column is Increased error. Misclassification rate (MR) for classification or mean square error (MSE) for regression. The larger the increased error the more important the variable is.
ODRF
Accuracy
plot.VarImp
data(body_fat)
y=body_fat[,1]
X=body_fat[,-1]
tree <- ODT(X, y, split = "mse")
(varimp <- VarImp(tree, type="impurity"))
forest <- ODRF(X, y, split = "mse", parallel = FALSE, ntrees=50)
(varimp <- VarImp(forest, type="impurity"))
(varimp <- VarImp(forest, X, y, type="permutation"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.