我要从agaricus.txt.train加载什么?

在XGBoost的basic walkthrough example中,我们首先加载数据集。

>>> dtrain = xgb.DMatrix('../data/agaricus.txt.train')
[20:37:22] 6513x127 matrix with 143286 entries loaded from ../data/agaricus.txt.train
>>> dtest = xgb.DMatrix('../data/agaricus.txt.test')
[20:37:23] 1611x127 matrix with 35442 entries loaded from ../data/agaricus.txt.test

但是,数据集似乎包含127个功能,而不是XGBoost的R package所记录的126个功能。

>>> dtrain.num_col()
127

此外,当将pred_contribs设置为True时,xgboost.Booster.predict将返回一个大小为(nsample,nfeats + 1)的矩阵。由于preds有128列,我们可以得出结论dtrain包含127个要素。

>>> param = {'max_depth':2,'eta':1,'silent':1,'objective':'binary:logistic'}
>>> watchlist = [(dtest,'eval'),(dtrain,'train')]
>>> num_round = 2
>>> bst = xgb.train(param,dtrain,num_round,watchlist)
[0] eval-error:0.042831 train-error:0.046522
[1] eval-error:0.021726 train-error:0.022263
>>> preds = bst.predict(dtest,output_margin=True,pred_contribs=True,approx_contribs=True)
>>> preds.shape
(1611,128)

这是怎么回事? xgboost.DMatrix是否将标签误认为是第127个特征?如果libsvm format txt file解析正确,那么preds为什么有128列?

Nokia_Czr 回答:我要从agaricus.txt.train加载什么?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3129184.html

大家都在问