From e1b5b9911301621a270d7792dc3f2b26f75bf70f Mon Sep 17 00:00:00 2001 From: kalenhaha Date: Tue, 18 Feb 2014 16:49:23 +0800 Subject: [PATCH] add in reg.conf for configuration demo --- demo/regression/reg.conf | 37 +++++++++++++++++++++++++++++++++ regression/xgboost_reg_main.cpp | 3 ++- regression/xgboost_reg_test.h | 10 ++++----- 3 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 demo/regression/reg.conf diff --git a/demo/regression/reg.conf b/demo/regression/reg.conf new file mode 100644 index 000000000..ee72ef960 --- /dev/null +++ b/demo/regression/reg.conf @@ -0,0 +1,37 @@ +boost_iterations=10 + +save_period=0 + +train_path= + +model_dir_path= + +validation_paths= + +validation_names=validation + +test_paths= + +test_names=test + +booster_type=1 + +do_reboost=0 + +bst:num_roots=0 + +bst:num_feature=3 + +learning_rate=0.01 + +min_child_weight=1 + +min_split_loss=0.1 + +max_depth=3 + +reg_lambda=0.1 + +subsample=1 + +use_layerwise=0 diff --git a/regression/xgboost_reg_main.cpp b/regression/xgboost_reg_main.cpp index f14284ad3..594069ca2 100644 --- a/regression/xgboost_reg_main.cpp +++ b/regression/xgboost_reg_main.cpp @@ -8,7 +8,8 @@ int main(int argc, char *argv[]){ char* config_path = "c:\\cygwin64\\home\\chen\\github\\xgboost\\demo\\regression\\reg.conf"; bool silent = false; RegBoostTrain train; - RegBoostTest test; train.train(config_path,false); + + RegBoostTest test; test.test(config_path,false); } \ No newline at end of file diff --git a/regression/xgboost_reg_test.h b/regression/xgboost_reg_test.h index b6183d412..2a9020ed6 100644 --- a/regression/xgboost_reg_test.h +++ b/regression/xgboost_reg_test.h @@ -45,7 +45,7 @@ namespace xgboost{ for(int i = 0; i < test_param.test_paths.size(); i++){ xgboost::regression::DMatrix test_data; test_data.LoadText(test_param.test_paths[i].c_str()); - sscanf(model_path,"%s/final.model",test_param.model_dir_path); + sprintf(model_path,"%s/final.model",test_param.model_dir_path); FileStream fin(fopen(model_path,"r")); reg_boost_learner->LoadModel(fin); fin.Close(); @@ -62,10 +62,10 @@ namespace xgboost{ int save_period; /* \brief the path of directory containing the saved models */ - const char* model_dir_path; + char model_dir_path[256]; /* \brief the path of directory containing the output prediction results */ - const char* pred_dir_path; + char pred_dir_path[256]; /* \brief the paths of test data sets */ std::vector test_paths; @@ -79,8 +79,8 @@ namespace xgboost{ * \param val value of the parameter */ inline void SetParam(const char *name,const char *val ){ - if( !strcmp("model_dir_path", name ) ) model_dir_path = val; - if( !strcmp("pred_dir_path", name ) ) model_dir_path = val; + if( !strcmp("model_dir_path", name ) ) strcpy(model_dir_path,val); + if( !strcmp("pred_dir_path", name ) ) strcpy(pred_dir_path,val); if( !strcmp("test_paths", name) ) { test_paths = StringProcessing::split(val,';'); }