Medial Code Documentation
Loading...
Searching...
No Matches
fit_stump.h
1
7#ifndef XGBOOST_TREE_FIT_STUMP_H_
8#define XGBOOST_TREE_FIT_STUMP_H_
9
10#if !defined(NOMINMAX) && defined(_WIN32)
11#define NOMINMAX
12#endif // !defined(NOMINMAX)
13
14#include <algorithm> // std::max
15
16#include "../common/common.h" // AssertGPUSupport
17#include "xgboost/base.h" // GradientPair
18#include "xgboost/context.h" // Context
19#include "xgboost/data.h" // MetaInfo
20#include "xgboost/host_device_vector.h" // HostDeviceVector
21#include "xgboost/linalg.h" // TensorView
22
23namespace xgboost {
24namespace tree {
25
26template <typename T>
27XGBOOST_DEVICE inline double CalcUnregularizedWeight(T sum_grad, T sum_hess) {
28 return -sum_grad / std::max(sum_hess, static_cast<double>(kRtEps));
29}
30
34void FitStump(Context const* ctx, MetaInfo const& info, HostDeviceVector<GradientPair> const& gpair,
35 bst_target_t n_targets, linalg::Vector<float>* out);
36} // namespace tree
37} // namespace xgboost
38#endif // XGBOOST_TREE_FIT_STUMP_H_
Copyright 2014-2023, XGBoost Contributors.
A device-and-host vector abstraction layer.
Copyright 2015-2023 by XGBoost Contributors.
#define XGBOOST_DEVICE
Tag function as usable by device.
Definition base.h:64
Copyright 2015-2023 by XGBoost Contributors.
Copyright 2021-2023 by XGBoost Contributors.
void FitStump(Context const *ctx, MetaInfo const &info, HostDeviceVector< GradientPair > const &gpair, bst_target_t n_targets, linalg::Vector< float > *out)
Fit a tree stump as an estimation of base_score.
Definition fit_stump.cc:69
namespace of xgboost
Definition base.h:90
std::uint32_t bst_target_t
Type for indexing into output targets.
Definition base.h:118
constexpr bst_float kRtEps
small eps gap for minimum split decision.
Definition base.h:319