different results across different runs with no change in parameters
I was able to get results that would replicate with xgboost up to 750 trees or so. With these parameters on the Kaggle Higgs boson problem:
param['bst:eta'] = 0.025 param['bst:max_depth'] = 6 param['eval_metric'] = 'auc' param['silent'] = 1 param['nthread'] = 32 num_round = 1100 threshold_ratio = 0.148
I get slightly different answers each time I run. Code for higgs-numpy.py here:
http://pastebin.com/EEK4FAQK
Code for higgs-pred.py here
http://pastebin.com/hRCL15X2
I don't think it is XGboost's issue.
I tried on my computer with one more param: param[seed]=173 And run twice, got the md5 result:
a96d522e4ecdf4293f4a96caae13f554 Nhiggs.pred_1.csv
a96d522e4ecdf4293f4a96caae13f554 Nhiggs.pred_2.csv
Without setting seed manually, I run twice but only 11 epoch, the result of md5 is:
6d9fb519aab5f5f5c7dac56f88ad37f8 Nhiggs.pred_1.csv
6d9fb519aab5f5f5c7dac56f88ad37f8 Nhiggs.pred_2.csv
Thanks for the quick response. I added param[seed] = '173' but the problem persisted on both my own computer and the 32 core EC2 machine I am using. So I did some testing with 5 runs across various number of epochs:
200 epochs 174f20f2a2e88d957292c3f1732d39b1 174f20f2a2e88d957292c3f1732d39b1 174f20f2a2e88d957292c3f1732d39b1 174f20f2a2e88d957292c3f1732d39b1 174f20f2a2e88d957292c3f1732d39b1
300 epochs 4309b524c736a39ea4591863f6768dce b38853f94555bba8dffc70c242c6bdad 4309b524c736a39ea4591863f6768dce 4309b524c736a39ea4591863f6768dce 4309b524c736a39ea4591863f6768dce
400 epochs 270f68e4143680823a460e6f7a49ed96 270f68e4143680823a460e6f7a49ed96 270f68e4143680823a460e6f7a49ed96 270f68e4143680823a460e6f7a49ed96 270f68e4143680823a460e6f7a49ed96
500 epochs f814246b479db8590c8609ca96410ac1 f814246b479db8590c8609ca96410ac1 0c64cc0c69d14179792f0e20561df91d a28887afd32ea04882b77bc47ef7fac9 a386b5cd1741bbe5cb9e97be4c6b67d9
As you see there is a difference starting at 300 epochs and by 500 epochs each run produces a different answer. So I ran a test with only one thread:
500 epochs with one thread 2e8f3ee01ed694238eab193ee50af222 2e8f3ee01ed694238eab193ee50af222 2e8f3ee01ed694238eab193ee50af222 2e8f3ee01ed694238eab193ee50af222 2e8f3ee01ed694238eab193ee50af222
No differences; so I suspect a race condition.
I cloned xgboost from git yesterday and built the so by running make from the python directory. The md5sum for my xgboost.so is 97276f7cdff5df189fdfcf40d0dbbf51.
I closed the issue by mistake, repoening...
This might happen, due to the arbitrary execution order of parallel column split selection, and when different split strategy have same reduction score. This should be rare since, I have add a comparison rule to encourage smaller feature index, but seems as james reported, this still can happen.
A possible quick fix, is to change schedule( dynamic, 1 ) to schedule(static) in line 181 of https://github.com/tqchen/xgboost/blob/master/booster/tree/xgboost_col_treemaker.hpp
Hi all, changing line 181 of col_treemaker doesn't work for me. I've observed different results on the same machine. Also on different machines I notice that - even loading the same model - predictions can differ.
BTW, I think it would be great if you can add a new feature to load a previously saved model and continue training from the last boosting round on. (I was not sure where I could post this request, sorry)
Back to the issue: I've compared the dump of 2 different models obtained from the same parameters and I can see that the initial boosters have just slight changes in the leaf values, while the whole tree structure is quite different for the final boosters...
An example of comparison for booster[0] extracted from two different runs (different leaf value!):
299:[f12<0.591000] yes=573,no=574,missing=574
573:leaf=-0.150482
574:leaf=0.162179
versus
299:[f12<0.591000] yes=573,no=574,missing=574
573:leaf=-0.150482
574:leaf=0.162180
An other example of comparison for booster[2] extracted from two different runs (different leaf split):
131:[f17<-1.632000] yes=257,no=258,missing=258
257:leaf=-0.171885
258:[f1<34.699501] yes=503,no=504,missing=504
503:leaf=0.070538
504:leaf=-0.159713
versus
131:[f17<-1.632000] yes=257,no=258,missing=258
257:[f11<1.392500] yes=501,no=502,missing=502
501:leaf=-0.044755
502:leaf=-0.190995
258:[f1<34.699501] yes=503,no=504,missing=504
503:leaf=0.070538
504:leaf=-0.159713
Seems the problem is floating point execution and since we are doing multi-threading here, different summation order of float causes the accuracy difference, which results in difference in latter trees.
For supporting continue training, you can open a new issue:) Actually it is already supported, but not documented feature
I will close this feature for now, since it is most likely to be floating point summation issue. The random seed problem is already fixed
A couple of articles about floating point summation for future reference: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.309.6586 http://www.eecs.berkeley.edu/~hdnguyen/public/papers/ARITH21_Fast_Sum.pdf https://publications.lip6.fr/index.php/publications/show/10315 http://cds.cern.ch/record/1696945/ https://hal.archives-ouvertes.fr/hal-00949355/en/