【发布时间】:2018-12-13 16:40:55
【问题描述】:
我正在尝试使用 XGBOOST 在 python 上运行回归问题:
import xgboost
global clf
clf = XGBRegressor(n_estimators = 500,
learning_rate = 0.05,
max_depth=6,
n_jobs=4,
alpha = 0.1)
clf.fit(X_train, y_train,
early_stopping_rounds = 5,
eval_set = validation, verbose=False)
predicted_test_tr = np.round(clf.predict(X_test))
但经过几次迭代,它会引发以下错误:
XGBoostError: b'[10:56:23] src/objective/regression_obj.cc:43: Check failed: info.labels_.size() != 0U (0 vs. 0) label set cannot be empty\n\nStack trace returned 7 entries:\n[bt] (0) 0 libxgboost.dylib 0x0000001a1971b7a1 dmlc::StackTrace() + 305\n[bt] (1) 1 libxgboost.dylib 0x0000001a1971b52f dmlc::LogMessageFatal::~LogMessageFatal() + 47\n[bt] (2) 2 libxgboost.dylib 0x0000001a19792d21 xgboost::obj::RegLossObj<xgboost::obj::LinearSquareLoss>::GetGradient(xgboost::HostDeviceVector<float>*, xgboost::MetaInfo const&, int, xgboost::HostDeviceVector<xgboost::detail::GradientPairInternal<float> >*) + 257\n[bt] (3) 3 libxgboost.dylib 0x0000001a19717496 xgboost::LearnerImpl::UpdateOneIter(int, xgboost::DMatrix*) + 1014\n[bt] (4) 4 libxgboost.dylib 0x0000001a1973369f XGBoosterUpdateOneIter + 79\n[bt] (5) 5 libffi.6.dylib 0x0000000110308884 ffi_call_unix64 + 76\n[bt] (6) 6 ??? 0x00007ffee1b29950 0x0 + 140732684998992\n\n'
我尝试将输入和输出转换为:
.apply(pd.to_numeric)
但是仍然报同样的错误;怎么解决?
【问题讨论】:
-
我认为你应该明确的对象功能。它可能有助于解决您的问题。在带有 multi 标签的分类中,如果你指定 binary loss 作为代价,你会得到类似的错误
-
我正在尝试解决回归问题;
-
我知道,我只是举了一个示例,其中我遇到了与您的错误相似的错误。我的观点是:如果可以的话,在 XGBRegressor 的调用中明确成本函数
-
我试图在参数部分明确指定函数:objective = "reg:linear";但它报告了同样的错误。
-
错误是否在
clf = XGBRegressor(...或clf.fit(...引发?
标签: python machine-learning label regression xgboost