Attempt to create an R package from prototype available at “Classification tree algorithm for grouped variables”.
This is a basic example which shows you how to solve a common problem:
library(dtrfgv)
data(rfgv_dataset)
data(group)
data <- rfgv_dataset
train <- data[which(data[,1]=="train"),-1] # negative index into the `data`
test <- data[which(data[,1]=="test"),-1] # object specifying all rows and all columns
validation<-data[which(data[,1]=="validation"),-1] # except the first column.
forest<-rfgv(train,
group=group,
groupImp=group,
ntree=4,
mtry_group=3,
sampvar=TRUE,
maxdepth=2,
replace=TRUE,
case_min=1,
sampsize=nrow(train),
mtry_var=rep(2,5),
grp.importance=TRUE,
test=test,
keep_forest=FALSE,
crit=1,
penalty="No")
print(forest$importance)
#> MeanDecrAcc MeanDecrAccNor
#> 1 -0.016400048 -0.0032800095
#> 2 0.212613378 0.0425226755
#> 3 -0.007915047 -0.0015830093
#> 4 -0.001320884 -0.0002641768
#> 5 0.016452991 0.0032905983