[英]Looping not working as expected in R, while tuning xgboost parameters
該問題基於:
R中的xgboost:xgb.cv如何將最佳參數傳遞給xgb.train
我試圖用不同的參數類似地循環:
for (iter in 1:100){
param <- list(objective = "binary:logistic",
eval_metric = "auc",
max_depth = sample(2:6,1),
eta = runif(.01,.1,.05),
gamma = runif(.01,.05,.1),
subsample = runif(.9,.8,.7),
colsample_bytree = runif(.8,.9,.5),
min_child_weight = sample(30:100,1),
max_delta_step = sample(1:10,1)
)
但這會引發錯誤,因為參數在第一次迭代時將值取為:
max_depth : int 6
eta : num(0)
gamma: num(0)
subsample : num(0)
colsample_bytree : num(0)
min_child_weight: int 63
max_delta_step: int 2
是什么導致這種行為?
好像我弄錯了runif函數。
這似乎正在工作:
param <- list(objective = "binary:logistic",
eval_metric = "auc",
max_depth = sample(2:6,1),
eta = runif(1,.01,.05),
gamma = runif(1,.01,.1),
subsample = runif(1,0.6,0.9),
colsample_bytree = runif(1,.5,1),
min_child_weight = sample(30:100,1),
max_delta_step = sample(1:10,1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.