online predict issue
I am using xgboost to predict online, but the result I get from online predict interface is diff with the result I get from batch interface, is there any thing I used error?
online predict interface:
// implementation of inline functions.
inline void Learner::Predict(const SparseBatch::Inst& inst,
bool output_margin,
std::vector
batch predict interface:
virtual void Predict(DMatrix* data,
bool output_margin,
std::vector
I have encountered this problem too. @tqchen
I think this should be a bug, mainly the following part of the code: ~/include/xgboost/learner.h
// implementation of inline functions.
inline void Learner::Predict(const SparseBatch::Inst& inst,
bool output_margin,
std::vector<bst_float>* out_preds,
unsigned ntree_limit) const {
gbm_->Predict(inst, out_preds, ntree_limit);
if (out_preds->size() == 1) {
(*out_preds)[0] += base_score_;
}
if (!output_margin) {
obj_->PredTransform(out_preds);
}
}
If you can comment conditions about (out_preds->size() == 1, you will get result you want. I do not know why the online forecast needs to add this condition, and batch prediction does not require if conditions? In addition, what does base_score_ parameter mean?
这里可能是一个bug,主要在线预测实现这部分。如果把if(out_preds->size() == 1)条件注释掉 就可以得到一致的结果,主要原因是每次加载模型时base_score_参数值都不相同,并且批量预测实现中没有用到base_score_这个参数,不清楚这个为什么?另外,base_score_参数的物理意义是什么? @tqchen
问题解决了吗?@earthwu