make python random seed invariant in each round

This commit is contained in:
tqchen 2014-05-24 20:57:39 -07:00
parent 76c44072d1
commit 278b788b34
2 changed files with 6 additions and 0 deletions

View File

@ -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)

View File

@ -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();