add with pbuffer info to model, allow xgb model to be saved in a more memory compact way

This commit is contained in:
tqchen
2015-05-06 15:43:15 -07:00
parent 3b4697786e
commit 7f7947f31c
4 changed files with 34 additions and 20 deletions

View File

@@ -64,7 +64,13 @@ class GBTree : public IGradBooster {
}
virtual void SaveModel(utils::IStream &fo, bool with_pbuffer) const {
utils::Assert(mparam.num_trees == static_cast<int>(trees.size()), "GBTree");
fo.Write(&mparam, sizeof(ModelParam));
if (with_pbuffer) {
fo.Write(&mparam, sizeof(ModelParam));
} else {
ModelParam p = mparam;
p.num_pbuffer = 0;
fo.Write(&p, sizeof(ModelParam));
}
for (size_t i = 0; i < trees.size(); ++i) {
trees[i]->SaveModel(fo);
}