Get the Variable Inclusion Counts
Computes the variable inclusion counts for a BART model.
get_var_counts_over_chain(bart_machine, type = "splits")
bart_machine |
An object of class “bartMachine”. |
type |
If “splits”, then the number of times each variable is chosen for a splitting rule is computed. If “trees”, then the number of times each variable appears in a tree is computed. |
Returns a matrix of counts of each predictor across all trees by Gibbs sample. Thus, the dimension is num_interations_after_burn_in
by p (where p is the number of predictors after dummifying factors and adding missingness dummies if specified by use_missing_data_dummies_as_covars).
Adam Kapelner and Justin Bleich
## Not run: #generate Friedman data set.seed(11) n = 200 p = 10 X = data.frame(matrix(runif(n * p), ncol = p)) y = 10 * sin(pi* X[ ,1] * X[,2]) +20 * (X[,3] -.5)^2 + 10 * X[ ,4] + 5 * X[,5] + rnorm(n) ##build BART regression model bart_machine = bartMachine(X, y, num_trees = 20) #get variable inclusion counts var_counts = get_var_counts_over_chain(bart_machine) print(var_counts) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.