I am trying to save the log of a boosting using sink
function, as following code:
require(xgboost)
require(R.utils)
data(iris)
train.model <- model.matrix(Sepal.Length~., iris)
dtrain <- xgb.DMatrix(data=train.model, label=iris$Sepal.Length)
xgb_grid = list(eta = 0.05, max_depth = 5, subsample = 0.7, gamma = 0.3,
min_child_weight = 1)
sink("evaluationLog.txt")
fit_boost <-xgb.cv(data = dtrain,
nrounds = 1000,
objective = "reg:linear",
eval_metric = "logloss",
params = xgb_grid,
colsample_bytree = 0.7,
early_stopping_rounds = 100,
nfold = 5,
prediction = TRUE,
maximize = FALSE
)
sink()
However I can't see "what's happening" since it's not printing the function's output and/or message.
My question is how can I can retrieve both a .txt
file with sink
and see what the function (in this case would be xgb.cv
) is printing?
Thank you!