CMS 3D CMS Logo

XGBooster.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_PatAlgos_XGBooster_h
2 #define PhysicsTools_PatAlgos_XGBooster_h
3 
4 #include <memory>
5 #include <string>
6 #include <vector>
7 #include <map>
8 #include <xgboost/c_api.h>
9 
10 namespace pat {
11  class XGBooster {
12  public:
13  XGBooster(std::string model_file);
14  XGBooster(std::string model_file, std::string model_features);
15 
19 
21  void reset();
22 
23  void set(std::string name, float value);
24 
25  float predict();
26 
27  private:
28  std::vector<float> features_;
29  std::map<std::string, unsigned int> feature_name_to_index_;
30  BoosterHandle booster_;
31  };
32 } // namespace pat
33 
34 #endif
void reset()
Reset feature values.
Definition: XGBooster.cc:71
XGBooster(std::string model_file)
Definition: XGBooster.cc:46
BoosterHandle booster_
Definition: XGBooster.h:30
Definition: HeavyIon.h:7
float predict()
Definition: XGBooster.cc:80
std::vector< float > features_
Definition: XGBooster.h:28
std::map< std::string, unsigned int > feature_name_to_index_
Definition: XGBooster.h:29
void addFeature(std::string name)
Definition: XGBooster.cc:73