7 #ifndef XGBOOST_FEATURE_MAP_H_
8 #define XGBOOST_FEATURE_MAP_H_
10 #include <xgboost/logging.h>
38 std::string fname, ftype;
39 while (is >> fid >> fname >> ftype) {
40 this->
PushBack(fid, fname.c_str(), ftype.c_str());
49 inline void PushBack(
int fid,
const char *fname,
const char *ftype) {
50 CHECK_EQ(fid,
static_cast<int>(names_.size()));
51 names_.emplace_back(fname);
52 types_.push_back(GetType(ftype));
60 inline size_t Size()
const {
64 inline const char*
Name(
size_t idx)
const {
65 CHECK_LT(idx, names_.size()) <<
"FeatureMap feature index exceed bound";
66 return names_[idx].c_str();
70 CHECK_LT(idx, names_.size()) <<
"FeatureMap feature index exceed bound";
80 inline static Type GetType(
const char* tname) {
84 if (!strcmp(
"int", tname))
return kInteger;
85 if (!strcmp(
"float", tname))
return kFloat;
87 LOG(FATAL) <<
"unknown feature type, use i for indicator and q for quantity";
91 std::vector<std::string> names_;
93 std::vector<Type> types_;
Feature map data structure to help text model dump. TODO(tqchen) consider make it even more lightweig...
Definition: feature_map.h:22
void Clear()
clear the feature map
Definition: feature_map.h:55
void LoadText(std::istream &is)
load feature map from input stream
Definition: feature_map.h:36
Type
type of feature maps
Definition: feature_map.h:25
@ kQuantitive
Definition: feature_map.h:27
@ kFloat
Definition: feature_map.h:29
@ kIndicator
Definition: feature_map.h:26
@ kInteger
Definition: feature_map.h:28
@ kCategorical
Definition: feature_map.h:30
void PushBack(int fid, const char *fname, const char *ftype)
push back feature map.
Definition: feature_map.h:49
const char * Name(size_t idx) const
Definition: feature_map.h:64
Type TypeOf(size_t idx) const
Definition: feature_map.h:69
size_t Size() const
Definition: feature_map.h:60
namespace of xgboost
Definition: base.h:90