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

@@ -58,13 +58,13 @@ class Booster: public learner::BoostLearner {
}
inline void LoadModelFromBuffer(const void *buf, size_t size) {
utils::MemoryFixSizeBuffer fs((void*)buf, size);
learner::BoostLearner::LoadModel(fs);
learner::BoostLearner::LoadModel(fs, true);
this->init_model = true;
}
inline const char *GetModelRaw(bst_ulong *out_len) {
model_str.resize(0);
utils::MemoryBufferStream fs(&model_str);
learner::BoostLearner::SaveModel(fs);
learner::BoostLearner::SaveModel(fs, false);
*out_len = static_cast<bst_ulong>(model_str.length());
if (*out_len == 0) {
return NULL;
@@ -323,7 +323,7 @@ extern "C"{
static_cast<Booster*>(handle)->LoadModel(fname);
}
void XGBoosterSaveModel(const void *handle, const char *fname) {
static_cast<const Booster*>(handle)->SaveModel(fname);
static_cast<const Booster*>(handle)->SaveModel(fname, false);
}
void XGBoosterLoadModelFromBuffer(void *handle, const void *buf, bst_ulong len) {
static_cast<Booster*>(handle)->LoadModelFromBuffer(buf, len);