Minor edits to coding style (#2835)

* Some minor changes to the code style

Some minor changes to the code style in file basic_walkthrough.py

* coding style changes

* coding style changes arrcording PEP8

* Update basic_walkthrough.py
This commit is contained in:
LevineHuang
2017-10-27 11:12:54 +08:00
committed by Yuan (Terry) Tang
parent d9d5293cdb
commit 91af8f7106
10 changed files with 51 additions and 52 deletions

View File

@@ -11,7 +11,7 @@ dtest = xgb.DMatrix('../data/agaricus.txt.test')
# lambda is the L2 regularizer
# you can also set lambda_bias which is L2 regularizer on the bias term
param = {'silent':1, 'objective':'binary:logistic', 'booster':'gblinear',
'alpha': 0.0001, 'lambda': 1 }
'alpha': 0.0001, 'lambda': 1}
# normally, you do not need to set eta (step_size)
# XGBoost uses a parallel coordinate descent algorithm (shotgun),
@@ -22,9 +22,9 @@ param = {'silent':1, 'objective':'binary:logistic', 'booster':'gblinear',
##
# the rest of settings are the same
##
watchlist = [(dtest,'eval'), (dtrain,'train')]
watchlist = [(dtest, 'eval'), (dtrain, 'train')]
num_round = 4
bst = xgb.train(param, dtrain, num_round, watchlist)
preds = bst.predict(dtest)
labels = dtest.get_label()
print ('error=%f' % ( sum(1 for i in range(len(preds)) if int(preds[i]>0.5)!=labels[i]) /float(len(preds))))
print('error=%f' % (sum(1 for i in range(len(preds)) if int(preds[i] > 0.5) != labels[i]) / float(len(preds))))