fix some bugs
This commit is contained in:
@@ -52,7 +52,8 @@ namespace xgboost{
|
||||
buffer_size += (*evals[i]).size();
|
||||
}
|
||||
char str[25];
|
||||
itoa(buffer_size,str,10);
|
||||
_itoa(buffer_size,str,10);
|
||||
base_model.SetParam("num_pbuffer",str);
|
||||
base_model.SetParam("num_pbuffer",str);
|
||||
}
|
||||
|
||||
@@ -71,6 +72,7 @@ namespace xgboost{
|
||||
*/
|
||||
inline void InitTrainer( void ){
|
||||
base_model.InitTrainer();
|
||||
InitModel();
|
||||
mparam.AdjustBase();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using namespace xgboost::regression;
|
||||
int main(int argc, char *argv[]){
|
||||
// char* config_path = argv[1];
|
||||
// bool silent = ( atoi(argv[2]) == 1 );
|
||||
char* config_path = "c:\\cygwin64\\home\\chen\\github\\gboost\\demo\\regression\\reg.conf";
|
||||
char* config_path = "c:\\cygwin64\\home\\chen\\github\\xgboost\\demo\\regression\\reg.conf";
|
||||
bool silent = false;
|
||||
RegBoostTrain train;
|
||||
RegBoostTest test;
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace xgboost{
|
||||
ConfigIterator config_itr(config_path);
|
||||
//Get the training data and validation data paths, config the Learner
|
||||
while (config_itr.Next()){
|
||||
printf("%s %s\n",config_itr.name(),config_itr.val());
|
||||
reg_boost_learner->SetParam(config_itr.name(),config_itr.val());
|
||||
train_param.SetParam(config_itr.name(),config_itr.val());
|
||||
}
|
||||
@@ -41,6 +42,7 @@ namespace xgboost{
|
||||
|
||||
//Load Data
|
||||
xgboost::regression::DMatrix train;
|
||||
printf("%s",train_param.train_path);
|
||||
train.LoadText(train_param.train_path);
|
||||
std::vector<const xgboost::regression::DMatrix*> evals;
|
||||
for(int i = 0; i < train_param.validation_data_paths.size(); i++){
|
||||
@@ -70,7 +72,7 @@ namespace xgboost{
|
||||
void SaveModel(const char* suffix){
|
||||
char model_path[256];
|
||||
//save the final round model
|
||||
sscanf(model_path,"%s/%s",train_param.model_dir_path,suffix);
|
||||
sprintf(model_path,"%s/%s",train_param.model_dir_path,suffix);
|
||||
FILE* file = fopen(model_path,"w");
|
||||
FileStream fin(file);
|
||||
reg_boost_learner->SaveModel(fin);
|
||||
@@ -85,10 +87,10 @@ namespace xgboost{
|
||||
int save_period;
|
||||
|
||||
/* \brief the path of training data set */
|
||||
const char* train_path;
|
||||
char train_path[256];
|
||||
|
||||
/* \brief the path of directory containing the saved models */
|
||||
const char* model_dir_path;
|
||||
char model_dir_path[256];
|
||||
|
||||
/* \brief the paths of validation data sets */
|
||||
std::vector<std::string> validation_data_paths;
|
||||
@@ -102,10 +104,12 @@ namespace xgboost{
|
||||
* \param val value of the parameter
|
||||
*/
|
||||
inline void SetParam(const char *name,const char *val ){
|
||||
if( !strcmp("boost_iterations", name ) ) boost_iterations = (float)atof( val );
|
||||
if( !strcmp("boost_iterations", name ) ) boost_iterations = atoi( val );
|
||||
if( !strcmp("save_period", name ) ) save_period = atoi( val );
|
||||
if( !strcmp("train_path", name ) ) train_path = val;
|
||||
if( !strcmp("model_dir_path", name ) ) model_dir_path = val;
|
||||
if( !strcmp("train_path", name ) ) strcpy(train_path,val);
|
||||
if( !strcmp("model_dir_path", name ) ) {
|
||||
strcpy(model_dir_path,val);
|
||||
}
|
||||
if( !strcmp("validation_paths", name) ) {
|
||||
validation_data_paths = StringProcessing::split(val,';');
|
||||
}
|
||||
|
||||
@@ -64,10 +64,9 @@ namespace xgboost{
|
||||
init = false;
|
||||
}
|
||||
}
|
||||
if( init ){
|
||||
labels.push_back( label );
|
||||
data.AddRow( findex, fvalue );
|
||||
}
|
||||
|
||||
labels.push_back( label );
|
||||
data.AddRow( findex, fvalue );
|
||||
|
||||
this->UpdateInfo();
|
||||
if( !silent ){
|
||||
|
||||
Reference in New Issue
Block a user