GBM2List | R Documentation |
Transform gbm object to a list of trees that can be used for rule condition extraction
GBM2List(gbm1,X)
gbm1 |
gbm object |
X |
predictor variable matrix |
a list of trees in an inTrees-required format
RF2List
library(gbm) data(iris) X <- iris[,1:(ncol(iris)-1)] target <- iris[,"Species"] gbmFit <- gbm(Species~ ., data=iris, n.tree = 400, interaction.depth = 10,distribution="multinomial") treeList <- GBM2List(gbmFit,X) ruleExec = extractRules(treeList,X) ruleExec <- unique(ruleExec) #ruleExec <- ruleExec[1:min(2000,length(ruleExec)),,drop=FALSE] ruleMetric <- getRuleMetric(ruleExec,X,target) ruleMetric <- pruneRule(ruleMetric,X,target) ruleMetric <- unique(ruleMetric) learner <- buildLearner(ruleMetric,X,target) pred <- applyLearner(learner,X) readableLearner <- presentRules(learner,colnames(X)) # more readable format err <- 1-sum(pred==target)/length(pred);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.