使用交叉验证XGboost

时间:2020-08-11 18:11:28

标签: python windows jupyter xgboost

我正在将xgb api用于python,并尝试执行xgb.cv时出现以下错误,

param = {'max_depth': 6, 'eta': 0.1,'objective' :'reg:squarederror','subsample':0.8 ,'gamma':0,
         'colsample_bytree':1,'nthread':cores,'base_score':y_train.mean(),'eval_metric':'rmse'}
num_round = 1
evallist = [(test, 'eval'), (train, 'train')]


xgb.cv(param, train, num_round, nfold=5,
           metrics={'error'}, seed=0,
           callbacks=[xgb.callback.print_evaluation(show_stdv=True)])
    
    
        OSError                                   Traceback (most recent call last)
        <ipython-input-29-9d56c9a868ed> in <module>
              5 xgb.cv(param, train, num_round, nfold=5,
              6        metrics={'error'}, seed=0,
        ----> 7        callbacks=[xgb.callback.print_evaluation(show_stdv=True)])
        
        ~\Anaconda3\lib\site-packages\xgboost\training.py in cv(params, dtrain, num_boost_round, nfold, stratified, folds, metrics, obj, feval, maximize, early_stopping_rounds, fpreproc, as_pandas, verbose_eval, show_stdv, seed, callbacks, shuffle)
            464     results = {}
            465     cvfolds = mknfold(dtrain, nfold, params, seed, metrics, fpreproc,
        --> 466                       stratified, folds, shuffle)
            467 
            468     # setup callbacks
        
        ~\Anaconda3\lib\site-packages\xgboost\training.py in mknfold(dall, nfold, param, seed, evals, fpreproc, stratified, folds, shuffle)
            323     for k in range(nfold):
            324         # perform the slicing using the indexes determined by the above methods
        --> 325         dtrain = dall.slice(in_idset[k])
            326         dtest = dall.slice(out_idset[k])
            327         # run preprocessing on the data set if needed
        
        ~\Anaconda3\lib\site-packages\xgboost\core.py in slice(self, rindex, allow_groups)
            955                                                  c_bst_ulong(len(rindex)),
            956                                                  ctypes.byref(res.handle),
        --> 957                                                  ctypes.c_int(1 if allow_groups else 0)))
            958         return res
            959 
        
        OSError: [WinError -529697949] Windows Error 0xe06d7363

我已经尝试安装和卸载XGB,但我认为这不是问题,因为我可以进行培训,问题出在我尝试进行交叉验证时。

我正在使用:

Python:3.7.3(默认值,2019年4月24日,15:29:51)[MSC v.1915 64位(AMD64)]

xgb。版本“ 1.1.0”

更新20200831

对我有用的是:

1。卸载xgboost

2。升级点子

3。使用pip3 install xgboost重新安装xgboost

0 个答案:

没有答案
相关问题