mattharrison / effective_xgboost_book

268 stars 30 forks source link

Mersenne Twister generator in chapter 4 #6

Open fizban99 opened 1 year ago

fizban99 commented 1 year ago

In chapter 4, the Mersenne Twister generator is used as a parameter of RandomState. According to the documentation, it seems that RandomState directly accepts a seed for its own Mersenne Twister generator, so it would be much simpler to just have:

rs = rn.RandomState(seed=42)

The result is not exactly the same because of the different ways the seed is considered in the two usages. The usage of RandomState shown on the book seems to be its legacy form, but probably is overcomplicating things for NumPy versions newer than 1.16.