diff --git a/python/xgboost.py b/python/xgboost.py index 690d0d4ed..a2389fbce 100644 --- a/python/xgboost.py +++ b/python/xgboost.py @@ -121,6 +121,8 @@ class Booster: assert isinstance(d,DMatrix) dmats = ( ctypes.c_void_p * len(cache) )(*[ d.handle for d in cache]) self.handle = ctypes.c_void_p( xglib.XGBoosterCreate( dmats, len(cache) ) ) + # default random seed + self.set_param( {"seed": 0} ) self.set_param( params ) def __del__(self): xglib.XGBoosterFree(self.handle) diff --git a/python/xgboost_python.cpp b/python/xgboost_python.cpp index 9ad0f34af..a325a20d4 100644 --- a/python/xgboost_python.cpp +++ b/python/xgboost_python.cpp @@ -130,6 +130,10 @@ namespace xgboost{ xgboost::regrank::RegRankBoostLearner::LoadModel(fname); this->init_model = true; } + inline void SetParam( const char *name, const char *val ){ + if( !strcmp( name, "seed" ) ) random::Seed(atoi(val)); + xgboost::regrank::RegRankBoostLearner::SetParam( name, val ); + } const float *Pred( const DMatrix &dmat, size_t *len, int bst_group ){ this->CheckInit();