xgboost.DMatrix可以通过set“silent = True”保持沉默

时间:2016-11-05 15:28:31

标签: python xgboost

我正在学习XGBoost。我想用XGBoost python api完成演示。 当我使用函数“xgboost.DMatrix”将数据设置为文件时,silent设置为True。但是,函数“xgboost.DMatrix”总是输出一些消息“[23:28:44] 1441x10矩阵,其中11528个条目从file_name加载”。我设置错误参数? reference

1 个答案:

答案 0 :(得分:1)

这很有趣。静默值被传递给Wrapper,但似乎包装器并没有真正使用它!

这会显示相应的代码https://github.com/dmlc/xgboost/blob/master/src/c_api/c_api.cc#L202

其中说:

int XGDMatrixCreateFromFile(const char *fname,
                            int silent,
                            DMatrixHandle *out) {
  API_BEGIN();
  if (rabit::IsDistributed()) {
    LOG(CONSOLE) << "XGBoost distributed mode detected, "
                 << "will split data among workers";
  }
  *out = new std::shared_ptr<DMatrix>(DMatrix::Load(fname, false, true));
  API_END();
}

即。即使沉默是一个参数,它也不会在函数中使用......(非常奇怪)

所以,现在看来,如果您正在使用任何包装器(Python,R,julia等),DMatrix的静默功能将无法正常工作。