xgboost
metric.h
Go to the documentation of this file.
1 
7 #ifndef XGBOOST_METRIC_H_
8 #define XGBOOST_METRIC_H_
9 
10 #include <dmlc/registry.h>
12 #include <xgboost/data.h>
13 #include <xgboost/base.h>
15 
16 #include <vector>
17 #include <string>
18 #include <functional>
19 #include <utility>
20 
21 namespace xgboost {
26 class Metric {
27  protected:
29 
30  public:
35  virtual void Configure(
36  const std::vector<std::pair<std::string, std::string> >& args) {}
45  virtual bst_float Eval(const HostDeviceVector<bst_float>& preds,
46  const MetaInfo& info,
47  bool distributed) = 0;
49  virtual const char* Name() const = 0;
51  virtual ~Metric() = default;
59  static Metric* Create(const std::string& name, GenericParameter const* tparam);
60 };
61 
67 struct MetricReg
68  : public dmlc::FunctionRegEntryBase<MetricReg,
69  std::function<Metric* (const char*)> > {
70 };
71 
85 #define XGBOOST_REGISTER_METRIC(UniqueId, Name) \
86  ::xgboost::MetricReg& __make_ ## MetricReg ## _ ## UniqueId ## __ = \
87  ::dmlc::Registry< ::xgboost::MetricReg>::Get()->__REGISTER__(Name)
88 } // namespace xgboost
89 #endif // XGBOOST_METRIC_H_
Registry entry for Metric factory functions. The additional parameter const char* param gives the val...
Definition: metric.h:67
float bst_float
float type, used for storing statistics
Definition: base.h:111
virtual void Configure(const std::vector< std::pair< std::string, std::string > > &args)
Configure the Metric with the specified parameters.
Definition: metric.h:35
static Metric * Create(const std::string &name, GenericParameter const *tparam)
create a metric according to name.
Meta information about dataset, always sit in memory.
Definition: data.h:39
The input data structure of xgboost.
Definition: generic_parameters.h:14
A device-and-host vector abstraction layer.
virtual const char * Name() const =0
namespace of xgboost
Definition: base.h:102
defines configuration macros of xgboost.
GenericParameter const * tparam_
Definition: metric.h:28
virtual ~Metric()=default
virtual destructor
virtual bst_float Eval(const HostDeviceVector< bst_float > &preds, const MetaInfo &info, bool distributed)=0
evaluate a specific metric
interface of evaluation metric used to evaluate model performance. This has nothing to do with traini...
Definition: metric.h:26