first version that reproduce binary classification demo

This commit is contained in:
tqchen
2014-08-16 15:44:35 -07:00
parent c4acb4fe01
commit 2c969ecf14
11 changed files with 286 additions and 20 deletions

View File

@@ -7,6 +7,7 @@
*/
#include <vector>
#include "../data.h"
#include "../utils/fmap.h"
namespace xgboost {
/*! \brief namespace for gradient booster */
@@ -63,6 +64,13 @@ class IGradBooster {
int64_t buffer_offset,
const std::vector<unsigned> &root_index,
std::vector<float> *out_preds) = 0;
/*!
* \brief dump the model in text format
* \param fmap feature map that may help give interpretations of feature
* \param option extra option of the dumo model
* \return a vector of dump for boosters
*/
virtual std::vector<std::string> DumpModel(const utils::FeatMap& fmap, int option) = 0;
// destrcutor
virtual ~IGradBooster(void){}
};

View File

@@ -141,6 +141,13 @@ class GBTree : public IGradBooster<FMatrix> {
}
}
}
virtual std::vector<std::string> DumpModel(const utils::FeatMap& fmap, int option) {
std::vector<std::string> dump;
for (size_t i = 0; i < trees.size(); i++) {
dump.push_back(trees[i]->DumpModel(fmap, option&1));
}
return dump;
}
protected:
// clear the model