Update train.py
This commit is contained in:
parent
8e5e3340a2
commit
cfd6c9e3b7
@ -22,8 +22,7 @@ xg_train = xgb.DMatrix( train_X, label=train_Y)
|
|||||||
xg_test = xgb.DMatrix(test_X, label=test_Y)
|
xg_test = xgb.DMatrix(test_X, label=test_Y)
|
||||||
# setup parameters for xgboost
|
# setup parameters for xgboost
|
||||||
param = {}
|
param = {}
|
||||||
# use logistic regression loss, use raw prediction before logistic transformation
|
# use softmax multi-class classification
|
||||||
# since we only need the rank
|
|
||||||
param['objective'] = 'multi:softmax'
|
param['objective'] = 'multi:softmax'
|
||||||
# scale weight of positive examples
|
# scale weight of positive examples
|
||||||
param['bst:eta'] = 0.1
|
param['bst:eta'] = 0.1
|
||||||
@ -35,4 +34,9 @@ param['num_class'] = 6
|
|||||||
watchlist = [ (xg_train,'train'), (xg_test, 'test') ]
|
watchlist = [ (xg_train,'train'), (xg_test, 'test') ]
|
||||||
num_round = 5
|
num_round = 5
|
||||||
bst = xgb.train(param, xg_train, num_round, watchlist );
|
bst = xgb.train(param, xg_train, num_round, watchlist );
|
||||||
|
# get prediction
|
||||||
|
pred = bst.predict( xg_test );
|
||||||
|
|
||||||
|
print 'error=%f' % sum(int(pred[i]) != test_Y[i] for i in len(test_Y)) / float(len(test_Y))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user