CMS 3D CMS Logo

XGBooster.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_XGBoost_XGBooster_h
2 #define PhysicsTools_XGBoost_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(const int iterationEnd = 0);
26  float predict(const std::vector<float>& features, const int iterationEnd = 0) const;
27 
28  private:
29  std::vector<float> features_;
30  std::map<std::string, unsigned int> feature_name_to_index_;
31  BoosterHandle booster_;
32  };
33 } // namespace pat
34 
35 #endif
void reset()
Reset feature values.
Definition: XGBooster.cc:72
XGBooster(std::string model_file)
Definition: XGBooster.cc:47
BoosterHandle booster_
Definition: XGBooster.h:31
Definition: HeavyIon.h:7
float predict(const int iterationEnd=0)
Definition: XGBooster.cc:81
std::vector< float > features(const reco::PreId &ecal, const reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
std::vector< float > features_
Definition: XGBooster.h:29
std::map< std::string, unsigned int > feature_name_to_index_
Definition: XGBooster.h:30
void addFeature(std::string name)
Definition: XGBooster.cc:74