有人可以解释如何在函数中计算R包中的Cover
列吗?xgboost
xgb.model.dt.tree
在文档中,它说Cover "是衡量受分割影响的观察数量的指标".
当您运行xgboost
此函数的文档中给出的以下代码时,Cover
树0的节点0为1628.2500.
data(agaricus.train, package='xgboost')
#Both dataset are list with two items, a sparse matrix and labels
#(labels = outcome column which will be learned).
#Each column of the sparse Matrix is a feature in one hot encoding format.
train <- agaricus.train
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
#agaricus.test$data@Dimnames[[2]] represents the column names of …
Run Code Online (Sandbox Code Playgroud) 有人可以解释如何Quality
在xgb.model.dt.tree
函数中计算xgboost R包中的列吗?
在文档中,它说Quality
"是与此特定节点中的拆分相关的增益".
当您运行以下代码时,在此函数的xgboost文档中给出,Quality
对于树0的节点0是4000.53,但我计算Gain
为2002.848
data(agaricus.train, package='xgboost')
train <- agarics.train
X = train$data
y = train$label
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
xgb.model.dt.tree(agaricus.train$data@Dimnames[[2]], model = bst)
p = rep(0.5,nrow(X))
L = which(X[,'odor=none']==0)
R = which(X[,'odor=none']==1)
pL = p[L]
pR = p[R]
yL = y[L]
yR = y[R]
GL = sum(pL-yL)
GR = sum(pR-yR)
G = …
Run Code Online (Sandbox Code Playgroud)