如果看到上篇,xgboost没有安装成功的可以提问我,本文主要讲xgboost的测试例子,例子模仿别人的,但补充了很多,希望能帮到更多人!
import sys,os
sys.path.append('E:\\xgboost-master\\xgboost-master\\wrapper')
import numpy as np
import scipy.sparse
import xgboost as xgb
dtrain = xgb.DMatrix('E:\\my-train.txt');
dtest = xgb.DMatrix('E:\\my-test.txt');
param = {'max_depth':6, 'eta':0.3, 'silent':1, 'objective':'binary:logistic'}
watchlist = [(dtest,'eval'), (dtrain,'train')]
num_round = 20
bst = xgb.train(param, dtrain, num_round, watchlist)
# this is prediction
preds = bst.predict(dtest)
labels = dtest.get_label()
print ('erro