Go to the documentation of this file.
5 #ifndef XGBOOST_COMMON_CATEGORICAL_H_
6 #define XGBOOST_COMMON_CATEGORICAL_H_
45 static_assert(
static_cast<bst_cat_t>(
static_cast<float>(kMaxCat)) == kMaxCat,
"");
46 static_assert(
static_cast<bst_cat_t>(
static_cast<float>(kMaxCat + 1)) != kMaxCat + 1,
"");
47 static_assert(
static_cast<float>(kMaxCat + 1) == kMaxCat,
"");
48 return cat < 0 || cat >= kMaxCat;
55 template <
bool val
idate = true>
65 if (pos.int_pos >= cats.
size()) {
76 LOG(FATAL) <<
"Invalid categorical value detected. Categorical value should be non-negative, "
77 "less than total number of categories in training data and less than " +
82 CHECK_GE(max_cat + 1, n_categories)
83 <<
"Maximum cateogry should not be lesser than the total number of categories.";
90 bool use_one_hot = n_cats < max_cat_to_onehot;
100 #endif // XGBOOST_COMMON_CATEGORICAL_H_
static XGBOOST_DEVICE Pos ToBitPos(index_type pos)
Definition: bitfield.h:77
#define XGBOOST_EXPECT(cond, ret)
Definition: base.h:75
A non-owning type with auxiliary methods defined for manipulating bits.
Definition: bitfield.h:59
macro for using C++11 enum class as DMLC parameter
void CheckMaxCat(float max_cat, size_t n_categories)
Definition: categorical.h:81
XGBOOST_DEVICE bool UseOneHot(uint32_t n_cats, uint32_t max_cat_to_onehot)
Whether should we use onehot encoding for categorical data.
Definition: categorical.h:89
defines configuration macros of xgboost.
Definition: categorical.h:94
uint32_t bst_feature_t
Type for data column (feature) index.
Definition: base.h:123
constexpr XGBOOST_DEVICE bool empty() const __span_noexcept
Definition: span.h:560
void InvalidCategory()
Definition: categorical.h:71
XGBOOST_DEVICE bool InvalidCat(float cat)
Definition: categorical.h:43
XGBOOST_DEVICE bool Check(Pos pos_v) const
Definition: bitfield.h:171
int32_t bst_cat_t
Categorical value type.
Definition: base.h:121
BitFieldContainer< uint32_t, LBitsPolicy< uint32_t, true >, true > CLBitField32
Definition: bitfield.h:231
FeatureType
Definition: data.h:41
span class implementation, based on ISO++20 span<T>. The interface should be the same.
Definition: span.h:148
The input data structure of xgboost.
constexpr XGBOOST_DEVICE index_type size() const __span_noexcept
Definition: span.h:553
BitFieldContainer< uint32_t, LBitsPolicy< uint32_t > > LBitField32
Definition: bitfield.h:230
XGBOOST_DEVICE bool Decision(common::Span< uint32_t const > cats, float cat, bool dft_left)
Definition: categorical.h:56
XGBOOST_DEVICE size_t Size() const
Definition: bitfield.h:184
XGBOOST_DEVICE bool IsCat(Span< FeatureType const > ft, bst_feature_t fidx)
Definition: categorical.h:34
XGBOOST_DEVICE bool operator()(FeatureType ft)
Definition: categorical.h:95
#define XGBOOST_DEVICE
Tag function as usable by device.
Definition: base.h:84
XGBOOST_DEVICE bst_cat_t AsCat(T const &v)
Definition: categorical.h:24
namespace of xgboost
Definition: base.h:110
constexpr bst_cat_t OutOfRangeCat()
Definition: categorical.h:38