xgboost
include
xgboost
metric.h
前往此文件的文档。
1
7
#ifndef XGBOOST_METRIC_H_
8
#define XGBOOST_METRIC_H_
9
10
#include <dmlc/registry.h>
11
#include <
xgboost/base.h
>
12
#include <
xgboost/data.h
>
13
#include <
xgboost/host_device_vector.h
>
14
#include <
xgboost/model.h
>
15
16
#include <functional>
17
#include <memory>
// shared_ptr
18
#include <string>
19
#include <utility>
20
#include <vector>
21
22
namespace
xgboost
{
23
struct
Context;
24
29
class
Metric
:
public
Configurable
{
30
protected
31
Context
const
*
ctx_
{
nullptr
};
32
33
public
38
virtual
void
Configure
(
39
const
std::vector<std::pair<std::string, std::string> >&) {}
46
void
LoadConfig
(
Json
const
&)
override
{}
53
void
SaveConfig
(
Json
* p_out)
const override
{
54
auto
& out = *p_out;
55
out[
"name"
] =
String
(this->
Name
());
56
}
57
64
virtual
double
Evaluate
(
HostDeviceVector<bst_float>
const
& preds,
65
std::shared_ptr<DMatrix> p_fmat) = 0;
66
68
virtual
const
char
*
Name
()
const
= 0;
70
~Metric
()
override
=
default
;
79
static
Metric
*
Create
(
const
std::string& name,
Context
const
* ctx);
80
};
81
87
struct
MetricReg
88
:
public
dmlc::FunctionRegEntryBase<MetricReg,
89
std::function<Metric* (const char*)> > {
90
};
91
105
#define XGBOOST_REGISTER_METRIC(UniqueId, Name) \
106
::xgboost::MetricReg& __make_ ## MetricReg ## _ ## UniqueId ## __ = \
107
::dmlc::Registry< ::xgboost::MetricReg>::Get()->__REGISTER__(Name)
108
}
// namespace xgboost
109
#endif
// XGBOOST_METRIC_H_
base.h
为 xgboost 定义配置宏和基本类型。
xgboost::HostDeviceVector< bst_float >
xgboost::Json
表示 JSON 格式的数据结构。
定义:
json.h:378
xgboost::Metric
用于评估模型性能的评估指标接口。这与训练无关...
定义:
metric.h:29
xgboost::Metric::SaveConfig
void SaveConfig(Json *p_out) const override
将配置保存到 JSON 对象。默认情况下,指标没有内部配置;覆盖此函数...
定义:
metric.h:53
xgboost::Metric::Configure
virtual void Configure(const std::vector< std::pair< std::string, std::string > > &)
使用指定的参数配置 Metric。
定义:
metric.h:38
xgboost::Metric::LoadConfig
void LoadConfig(Json const &) override
从 JSON 对象加载配置。默认情况下,指标没有内部配置;覆盖此函数...
定义:
metric.h:46
xgboost::Metric::Name
virtual const char * Name() const =0
xgboost::Metric::Create
static Metric * Create(const std::string &name, Context const *ctx)
根据名称创建一个指标。
xgboost::Metric::ctx_
Context const * ctx_
定义:
metric.h:31
xgboost::Metric::~Metric
~Metric() override=default
虚析构函数
xgboost::Metric::Evaluate
virtual double Evaluate(HostDeviceVector< bst_float > const &preds, std::shared_ptr< DMatrix > p_fmat)=0
以 DMatrix 作为输入评估一个指标。
data.h
xgboost 的输入数据结构。
host_device_vector.h
设备和主机向量抽象层。
model.h
定义 XGBoost 中不同组件的抽象接口。
xgboost
多目标树的核心数据结构。
定义:
base.h:89
xgboost::String
JsonString String
定义:
json.h:609
xgboost::Configurable
定义:
model.h:31
xgboost::Context
XGBoost 的运行时上下文。包含线程和设备等信息。
定义:
context.h:133
xgboost::MetricReg
Metric 工厂函数的注册表条目。附加参数 const char* param 提供值...
定义:
metric.h:89
生成于 Mon May 26 2025 21:34:52,通过
1.9.1 为 xgboost 生成