add batch running

This commit is contained in:
tqchen 2014-03-20 16:27:24 -07:00
parent 255b1f4043
commit db285cc4ba
2 changed files with 30 additions and 14 deletions

View File

@ -4,23 +4,20 @@ python mapfeat.py
# split train and test # split train and test
python mknfold.py agaricus.txt 1 python mknfold.py agaricus.txt 1
# training # training
../../xgboost mushroom.conf num_round=1 model_out=full.model bst:max_depth=3 ../../xgboost mushroom.conf num_round=2 model_out=full.model bst:max_depth=3
../../xgboost mushroom.conf task=dump model_in=full.model fmap=featmap.txt name_dump=dump.full.txt ../../xgboost mushroom.conf task=dump model_in=full.model fmap=featmap.txt name_dump=dump.full.txt
# constrain # major element of batch running: add batch prefix to each setting, batch:run=1 will run that action
../../xgboost mushroom.conf num_round=1 model_out=ban.model bst:max_depth=3 bst:fban=22-31
# constrain ../../xgboost mushroom.conf model_in=full.model model_out=m1.model task=interact\
../../xgboost mushroom.conf num_round=1 model_out=pass.model bst:max_depth=3 bst:fdefault=-1 bst:fpass=22-31 batch:interact:booster_index=0 batch:bst:interact:remove=1 batch:run=1\
batch:interact:booster_index=1 batch:bst:interact:remove=1 batch:run=1\
batch:interact:booster_index=1 batch:bst:interact:expand=9 batch:run=1\
../../xgboost mushroom.conf task=dump model_in=ban.model fmap=featmap.txt name_dump=dump.ban.txt ../../xgboost mushroom.conf task=dump model_in=m1.model fmap=featmap.txt name_dump=dump.m1.txt
../../xgboost mushroom.conf task=dump model_in=pass.model fmap=featmap.txt name_dump=dump.pass.txt
echo "========full=======" echo "========full======="
cat dump.full.txt cat dump.full.txt
echo "========ban=======" echo "========m1======="
cat dump.ban.txt cat dump.m1.txt
echo "========pass======="
cat dump.pass.txt

View File

@ -73,6 +73,9 @@ namespace xgboost{
if( !strcmp("name_pred", name ) ) name_pred = val; if( !strcmp("name_pred", name ) ) name_pred = val;
if( !strcmp("dump_stats", name ) ) dump_model_stats = atoi( val ); if( !strcmp("dump_stats", name ) ) dump_model_stats = atoi( val );
if( !strcmp("interact:action", name ) ) interact_action = val; if( !strcmp("interact:action", name ) ) interact_action = val;
if( !strncmp("batch:", name, 6 ) ){
cfg_batch.PushBack( name + 6, val );
}
if( !strncmp("eval[", name, 5 ) ) { if( !strncmp("eval[", name, 5 ) ) {
char evname[ 256 ]; char evname[ 256 ];
utils::Assert( sscanf( name, "eval[%[^]]", evname ) == 1, "must specify evaluation name for display"); utils::Assert( sscanf( name, "eval[%[^]]", evname ) == 1, "must specify evaluation name for display");
@ -167,13 +170,27 @@ namespace xgboost{
inline void TaskInteractive( void ){ inline void TaskInteractive( void ){
const time_t start = time( NULL ); const time_t start = time( NULL );
unsigned long elapsed = 0; unsigned long elapsed = 0;
learner.UpdateInteract( interact_action ); int batch_action = 0;
cfg_batch.BeforeFirst();
while( cfg_batch.Next() ){
if( !strcmp( cfg_batch.name(), "run" ) ){
learner.UpdateInteract( interact_action );
batch_action += 1;
} else{
learner.SetParam( cfg_batch.name(), cfg_batch.val() );
}
}
if( batch_action == 0 ){
learner.UpdateInteract( interact_action );
}
utils::Assert( model_out != "NULL", "interactive mode must specify model_out" ); utils::Assert( model_out != "NULL", "interactive mode must specify model_out" );
this->SaveModel( model_out.c_str() ); this->SaveModel( model_out.c_str() );
elapsed = (unsigned long)(time(NULL) - start); elapsed = (unsigned long)(time(NULL) - start);
if( !silent ){ if( !silent ){
printf("\ninteractive update, %lu sec in all\n", elapsed ); printf("\ninteractive update, %d batch actions, %lu sec in all\n", batch_action, elapsed );
} }
} }
@ -245,6 +262,8 @@ namespace xgboost{
std::vector<std::string> eval_data_names; std::vector<std::string> eval_data_names;
/*! \brief saves configurations */ /*! \brief saves configurations */
utils::ConfigSaver cfg; utils::ConfigSaver cfg;
/*! \brief batch configurations */
utils::ConfigSaver cfg_batch;
private: private:
DMatrix data; DMatrix data;
std::vector<DMatrix*> deval; std::vector<DMatrix*> deval;