xgboost

data.h
Go to the documentation of this file.
1
7 #ifndef XGBOOST_DATA_H_
8 #define XGBOOST_DATA_H_
9
10 #include <dmlc/base.h>
11 #include <dmlc/data.h>
12 #include <dmlc/serializer.h>
13 #include <xgboost/base.h>
14 #include <xgboost/span.h>
15 #include <xgboost/host_device_vector.h>
16
17 #include <memory>
18 #include <numeric>
19 #include <algorithm>
20 #include <string>
21 #include <utility>
22 #include <vector>
23
24 namespace xgboost {
25 // forward declare dmatrix.
26 class DMatrix;
27
29 enum class DataType : uint8_t {
30 kFloat32 = 1,
31 kDouble = 2,
32 kUInt32 = 3,
33 kUInt64 = 4,
34 kStr = 5
35 };
36
37 enum class FeatureType : uint8_t {
38 kNumerical,
39 kCategorical
40 };
41
45 class MetaInfo {
46 public:
48 static constexpr uint64_t kNumField = 11;
49
51 uint64_t num_row_{0}; // NOLINT
53 uint64_t num_col_{0}; // NOLINT
55 uint64_t num_nonzero_{0}; // NOLINT
57 HostDeviceVector<bst_float> labels_; // NOLINT
62 std::vector<bst_group_t> group_ptr_; // NOLINT
64 HostDeviceVector<bst_float> weights_; // NOLINT
70 HostDeviceVector<bst_float> base_margin_; // NOLINT
74 HostDeviceVector<bst_float> labels_lower_bound_; // NOLINT
78 HostDeviceVector<bst_float> labels_upper_bound_; // NOLINT
79
83 std::vector<std::string> feature_type_names;
87 std::vector<std::string> feature_names;
88 /*
89 * \brief Type of each feature. Automatically set when feature_type_names is specifed.
90 */
91 HostDeviceVector<FeatureType> feature_types;
92 /*
93 * \brief Weight of each feature, used to define the probability of each feature being
94 * selected when using column sampling.
95 */
96 HostDeviceVector<float> feature_weigths;
97
99 MetaInfo() = default;
100 MetaInfo(MetaInfo&& that) = default;
101 MetaInfo& operator=(MetaInfo&& that) = default;
102 MetaInfo& operator=(MetaInfo const& that) = delete;
103
107 void Validate(int32_t device) const;
108
109 MetaInfo Slice(common::Span<int32_t const> ridxs) const;
115 inline bst_float GetWeight(size_t i) const {
116 return weights_.Size() != 0 ? weights_.HostVector()[i] : 1.0f;
117 }
119 inline const std::vector<size_t>& LabelAbsSort() const {
120 if (label_order_cache_.size() == labels_.Size()) {
121 return label_order_cache_;
122 }
123 label_order_cache_.resize(labels_.Size());
124 std::iota(label_order_cache_.begin(), label_order_cache_.end(), 0);
125 const auto& l = labels_.HostVector();
126 XGBOOST_PARALLEL_SORT(label_order_cache_.begin(), label_order_cache_.end(),
127 [&l](size_t i1, size_t i2) {return std::abs(l[i1]) < std::abs(l[i2]);});
128
129 return label_order_cache_;
130 }
132 void Clear();
137 void LoadBinary(dmlc::Stream* fi);
142 void SaveBinary(dmlc::Stream* fo) const;
150 void SetInfo(const char* key, const void* dptr, DataType dtype, size_t num);
160 void SetInfo(const char* key, std::string const& interface_str);
161
162 void GetInfo(char const* key, bst_ulong* out_len, DataType dtype,
163 const void** out_dptr) const;
164
165 void SetFeatureInfo(const char *key, const char **info, const bst_ulong size);
166 void GetFeatureInfo(const char *field, std::vector<std::string>* out_str_vecs) const;
167
168 /*
169 * \brief Extend with other MetaInfo.
170 *
171 * \param that The other MetaInfo object.
172 *
173 * \param accumulate_rows Whether rows need to be accumulated in this function. If
174 * client code knows number of rows in advance, set this parameter to false.
175 */
176 void Extend(MetaInfo const& that, bool accumulate_rows);
177
178 private:
180 mutable std::vector<size_t> label_order_cache_;
181 };
182
184 struct Entry {
186 bst_feature_t index;
188 bst_float fvalue;
190 Entry() = default;
196 XGBOOST_DEVICE Entry(bst_feature_t index, bst_float fvalue) : index(index), fvalue(fvalue) {}
198 inline static bool CmpValue(const Entry& a, const Entry& b) {
199 return a.fvalue < b.fvalue;
200 }
201 inline bool operator==(const Entry& other) const {
202 return (this->index == other.index && this->fvalue == other.fvalue);
203 }
204 };
205
209 struct BatchParam {
211 int gpu_id;
213 int max_bin{0};
215 size_t gpu_page_size;
216 BatchParam() = default;
217 BatchParam(int32_t device, int32_t max_bin, size_t gpu_page_size = 0)
218 : gpu_id{device}, max_bin{max_bin}, gpu_page_size{gpu_page_size} {}
219 inline bool operator!=(const BatchParam& other) const {
220 return gpu_id != other.gpu_id || max_bin != other.max_bin ||
221 gpu_page_size != other.gpu_page_size;
222 }
223 };
224
225 struct HostSparsePageView {
226 using Inst = common::Span<Entry const>;
227
228 common::Span<bst_row_t const> offset;
229 common::Span<Entry const> data;
230
231 Inst operator[](size_t i) const {
232 auto size = *(offset.data() + i + 1) - *(offset.data() + i);
233 return {data.data() + *(offset.data() + i),
234 static_cast<Inst::index_type>(size)};
235 }
236
237 size_t Size() const { return offset.size() == 0 ? 0 : offset.size() - 1; }
238 };
239
243 class SparsePage {
244 public:
245 // Offset for each row.
246 HostDeviceVector<bst_row_t> offset;
248 HostDeviceVector<Entry> data;
249
250 size_t base_rowid {0};
251
253 using Inst = common::Span<Entry const>;
254
255 HostSparsePageView GetView() const {
256 return {offset.ConstHostSpan(), data.ConstHostSpan()};
257 }
258
259
261 SparsePage() {
262 this->Clear();
263 }
264
266 inline size_t Size() const {
267 return offset.Size() == 0 ? 0 : offset.Size() - 1;
268 }
269
271 inline size_t MemCostBytes() const {
272 return offset.Size() * sizeof(size_t) + data.Size() * sizeof(Entry);
273 }
274
276 inline void Clear() {
277 base_rowid = 0;
278 auto& offset_vec = offset.HostVector();
279 offset_vec.clear();
280 offset_vec.push_back(0);
281 data.HostVector().clear();
282 }
283
285 inline void SetBaseRowId(size_t row_id) {
286 base_rowid = row_id;
287 }
288
289 SparsePage GetTranspose(int num_columns) const;
290
291 void SortRows() {
292 auto ncol = static_cast<bst_omp_uint>(this->Size());
293 dmlc::OMPException exc;
294 #pragma omp parallel for schedule(dynamic, 1)
295 for (bst_omp_uint i = 0; i < ncol; ++i) {
296 exc.Run([&]() {
297 if (this->offset.HostVector()[i] < this->offset.HostVector()[i + 1]) {
298 std::sort(
299 this->data.HostVector().begin() + this->offset.HostVector()[i],
300 this->data.HostVector().begin() + this->offset.HostVector()[i + 1],
301 Entry::CmpValue);
302 }
303 });
304 }
305 exc.Rethrow();
306 }
307
318 template <typename AdapterBatchT>
319 uint64_t Push(const AdapterBatchT& batch, float missing, int nthread);
320
325 void Push(const SparsePage &batch);
330 void PushCSC(const SparsePage& batch);
331 };
332
333 class CSCPage: public SparsePage {
334 public:
335 CSCPage() : SparsePage() {}
336 explicit CSCPage(SparsePage page) : SparsePage(std::move(page)) {}
337 };
338
339 class SortedCSCPage : public SparsePage {
340 public:
341 SortedCSCPage() : SparsePage() {}
342 explicit SortedCSCPage(SparsePage page) : SparsePage(std::move(page)) {}
343 };
344
345 class EllpackPageImpl;
352 class EllpackPage {
353 public:
360 EllpackPage();
361
368 explicit EllpackPage(DMatrix* dmat, const BatchParam& param);
369
371 ~EllpackPage();
372
373 EllpackPage(EllpackPage&& that);
374
376 size_t Size() const;
377
379 void SetBaseRowId(size_t row_id);
380
381 const EllpackPageImpl* Impl() const { return impl_.get(); }
382 EllpackPageImpl* Impl() { return impl_.get(); }
383
384 private:
385 std::unique_ptr<EllpackPageImpl> impl_;
386 };
387
388 template<typename T>
389 class BatchIteratorImpl {
390 public:
391 virtual ~BatchIteratorImpl() = default;
392 virtual T& operator*() = 0;
393 virtual const T& operator*() const = 0;
394 virtual void operator++() = 0;
395 virtual bool AtEnd() const = 0;
396 };
397
398 template<typename T>
399 class BatchIterator {
400 public:
401 using iterator_category = std::forward_iterator_tag; // NOLINT
402 explicit BatchIterator(BatchIteratorImpl<T>* impl) { impl_.reset(impl); }
403
404 void operator++() {
405 CHECK(impl_ != nullptr);
406 ++(*impl_);
407 }
408
409 T& operator*() {
410 CHECK(impl_ != nullptr);
411 return *(*impl_);
412 }
413
414 const T& operator*() const {
415 CHECK(impl_ != nullptr);
416 return *(*impl_);
417 }
418
419 bool operator!=(const BatchIterator&) const {
420 CHECK(impl_ != nullptr);
421 return !impl_->AtEnd();
422 }
423
424 bool AtEnd() const {
425 CHECK(impl_ != nullptr);
426 return impl_->AtEnd();
427 }
428
429 private:
430 std::shared_ptr<BatchIteratorImpl<T>> impl_;
431 };
432
433 template<typename T>
434 class BatchSet {
435 public:
436 explicit BatchSet(BatchIterator<T> begin_iter) : begin_iter_(std::move(begin_iter)) {}
437 BatchIterator<T> begin() { return begin_iter_; } // NOLINT
438 BatchIterator<T> end() { return BatchIterator<T>(nullptr); } // NOLINT
439
440 private:
441 BatchIterator<T> begin_iter_;
442 };
443
444 struct XGBAPIThreadLocalEntry;
445
449 class DMatrix {
450 public:
452 DMatrix() = default;
454 virtual MetaInfo& Info() = 0;
455 virtual void SetInfo(const char *key, const void *dptr, DataType dtype,
456 size_t num) {
457 this->Info().SetInfo(key, dptr, dtype, num);
458 }
459 virtual void SetInfo(const char* key, std::string const& interface_str) {
460 this->Info().SetInfo(key, interface_str);
461 }
463 virtual const MetaInfo& Info() const = 0;
464
466 XGBAPIThreadLocalEntry& GetThreadLocal() const;
467
471 template<typename T>
472 BatchSet<T> GetBatches(const BatchParam& param = {});
473 template <typename T>
474 bool PageExists() const;
475
476 // the following are column meta data, should be able to answer them fast.
478 virtual bool SingleColBlock() const = 0;
480 virtual ~DMatrix();
481
483 bool IsDense() const {
484 return Info().num_nonzero_ == Info().num_row_ * Info().num_col_;
485 }
486
497 static DMatrix* Load(const std::string& uri,
498 bool silent,
499 bool load_row_split,
500 const std::string& file_format = "auto",
501 size_t page_size = kPageSize);
502
515 template <typename AdapterT>
516 static DMatrix* Create(AdapterT* adapter, float missing, int nthread,
517 const std::string& cache_prefix = "",
518 size_t page_size = kPageSize);
519
538 template <typename DataIterHandle, typename DMatrixHandle,
539 typename DataIterResetCallback, typename XGDMatrixCallbackNext>
540 static DMatrix *Create(DataIterHandle iter, DMatrixHandle proxy,
541 DataIterResetCallback *reset,
542 XGDMatrixCallbackNext *next, float missing,
543 int nthread,
544 int max_bin);
545
546 virtual DMatrix *Slice(common::Span<int32_t const> ridxs) = 0;
549 static const size_t kPageSize = 32UL << 12UL;
550
551 protected:
552 virtual BatchSet<SparsePage> GetRowBatches() = 0;
553 virtual BatchSet<CSCPage> GetColumnBatches() = 0;
554 virtual BatchSet<SortedCSCPage> GetSortedColumnBatches() = 0;
555 virtual BatchSet<EllpackPage> GetEllpackBatches(const BatchParam& param) = 0;
556
557 virtual bool EllpackExists() const = 0;
558 virtual bool SparsePageExists() const = 0;
559 };
560
561 template<>
562 inline BatchSet<SparsePage> DMatrix::GetBatches(const BatchParam&) {
563 return GetRowBatches();
564 }
565
566 template<>
567 inline bool DMatrix::PageExists<EllpackPage>() const {
568 return this->EllpackExists();
569 }
570
571 template<>
572 inline bool DMatrix::PageExists<SparsePage>() const {
573 return this->SparsePageExists();
574 }
575
576 template<>
577 inline BatchSet<CSCPage> DMatrix::GetBatches(const BatchParam&) {
578 return GetColumnBatches();
579 }
580
581 template<>
582 inline BatchSet<SortedCSCPage> DMatrix::GetBatches(const BatchParam&) {
583 return GetSortedColumnBatches();
584 }
585
586 template<>
587 inline BatchSet<EllpackPage> DMatrix::GetBatches(const BatchParam& param) {
588 return GetEllpackBatches(param);
589 }
590 } // namespace xgboost
591
592 namespace dmlc {
593 DMLC_DECLARE_TRAITS(is_pod, xgboost::Entry, true);
594
595 namespace serializer {
596
597 template <>
598 struct Handler<xgboost::Entry> {
599 inline static void Write(Stream* strm, const xgboost::Entry& data) {
600 strm->Write(data.index);
601 strm->Write(data.fvalue);
602 }
603
604 inline static bool Read(Stream* strm, xgboost::Entry* data) {
605 return strm->Read(&data->index) && strm->Read(&data->fvalue);
606 }
607 };
608
609 } // namespace serializer
610 } // namespace dmlc
611 #endif // XGBOOST_DATA_H_
xgboost::MetaInfo::GetFeatureInfo
void GetFeatureInfo(const char *field, std::vector< std::string > *out_str_vecs) const
xgboost::BatchIteratorImpl::operator++
virtual void operator++()=0
xgboost::Entry::index
bst_feature_t index
feature index
Definition: data.h:186
xgboost::DMatrix::Info
virtual MetaInfo & Info()=0
meta information of the dataset
xgboost::BatchParam::max_bin
int max_bin
Maximum number of bins per feature for histograms.
Definition: data.h:213
xgboost::MetaInfo::feature_type_names
std::vector< std::string > feature_type_names
Name of type for each feature provided by users. Eg. "int"/"float"/"i"/"q".
Definition: data.h:83
xgboost::DMatrix::GetEllpackBatches
virtual BatchSet< EllpackPage > GetEllpackBatches(const BatchParam &param)=0
xgboost::MetaInfo::num_row_
uint64_t num_row_
number of rows in the data
Definition: data.h:51
xgboost::HostSparsePageView::data
common::Span< Entry const > data
Definition: data.h:229
xgboost::BatchIteratorImpl::~BatchIteratorImpl
virtual ~BatchIteratorImpl()=default
xgboost::SparsePage::Size
size_t Size() const
Definition: data.h:266
xgboost::SparsePage::SetBaseRowId
void SetBaseRowId(size_t row_id)
Set the base row id for this page.
Definition: data.h:285
xgboost::DataType::kUInt64
@ kUInt64
xgboost::CSCPage::CSCPage
CSCPage()
Definition: data.h:335
dmlc
Definition: data.h:592
xgboost::MetaInfo::LabelAbsSort
const std::vector< size_t > & LabelAbsSort() const
get sorted indexes (argsort) of labels by absolute value (used by cox loss)
Definition: data.h:119
xgboost::DMatrix::~DMatrix
virtual ~DMatrix()
virtual destructor
xgboost::EllpackPage
A page stored in ELLPACK format.
Definition: data.h:352
xgboost::SparsePage
In-memory storage unit of sparse batch, stored in CSR format.
Definition: data.h:243
xgboost::SparsePage::Push
uint64_t Push(const AdapterBatchT &batch, float missing, int nthread)
Pushes external data batch onto this page.
xgboost::CSCPage::CSCPage
CSCPage(SparsePage page)
Definition: data.h:336
xgboost::common::Span::index_type
std::size_t index_type
Definition: span.h:421
xgboost::SparsePage::SortRows
void SortRows()
Definition: data.h:291
xgboost::Entry
Element from a sparse vector.
Definition: data.h:184
xgboost::BatchIterator::operator++
void operator++()
Definition: data.h:404
xgboost::MetaInfo::base_margin_
HostDeviceVector< bst_float > base_margin_
initialized margins, if specified, xgboost will start from this init margin can be used to specify in...
Definition: data.h:70
xgboost::EllpackPage::Impl
const EllpackPageImpl * Impl() const
Definition: data.h:381
xgboost::DMatrix::GetRowBatches
virtual BatchSet< SparsePage > GetRowBatches()=0
xgboost::HostDeviceVector< bst_float >
xgboost::BatchSet::BatchSet
BatchSet(BatchIterator< T > begin_iter)
Definition: data.h:436
host_device_vector.h
A device-and-host vector abstraction layer.
xgboost::DMatrix::SingleColBlock
virtual bool SingleColBlock() const =0
xgboost::SortedCSCPage::SortedCSCPage
SortedCSCPage(SparsePage page)
Definition: data.h:342
xgboost::MetaInfo::Clear
void Clear()
clear all the information
xgboost::BatchIterator::AtEnd
bool AtEnd() const
Definition: data.h:424
xgboost::EllpackPage::Size
size_t Size() const
xgboost::SortedCSCPage::SortedCSCPage
SortedCSCPage()
Definition: data.h:341
xgboost::DMatrix::SetInfo
virtual void SetInfo(const char *key, std::string const &interface_str)
Definition: data.h:459
xgboost::BatchIterator::BatchIterator
BatchIterator(BatchIteratorImpl< T > *impl)
Definition: data.h:402
xgboost::MetaInfo::SetInfo
void SetInfo(const char *key, const void *dptr, DataType dtype, size_t num)
Set information in the meta info.
base.h
defines configuration macros of xgboost.
xgboost::MetaInfo::MetaInfo
MetaInfo()=default
default constructor
xgboost::BatchParam::operator!=
bool operator!=(const BatchParam &other) const
Definition: data.h:219
xgboost::MetaInfo::labels_lower_bound_
HostDeviceVector< bst_float > labels_lower_bound_
lower bound of the label, to be used for survival analysis (censored regression)
Definition: data.h:74
xgboost::HostDeviceVector::ConstHostSpan
common::Span< T const > ConstHostSpan() const
Definition: host_device_vector.h:114
xgboost::MetaInfo::Slice
MetaInfo Slice(common::Span< int32_t const > ridxs) const
xgboost::BatchIteratorImpl
Definition: data.h:389
DataIterHandle
void * DataIterHandle
handle to a external data iterator
Definition: c_api.h:229
xgboost::BatchSet::begin
BatchIterator< T > begin()
Definition: data.h:437
xgboost::BatchParam::BatchParam
BatchParam()=default
xgboost::MetaInfo::num_col_
uint64_t num_col_
number of columns in the data
Definition: data.h:53
xgboost::MetaInfo::SetFeatureInfo
void SetFeatureInfo(const char *key, const char **info, const bst_ulong size)
xgboost::MetaInfo::group_ptr_
std::vector< bst_group_t > group_ptr_
the index of begin and end of a group needed when the learning task is ranking.
Definition: data.h:62
xgboost::BatchIterator::operator*
const T & operator*() const
Definition: data.h:414
xgboost::BatchIterator::operator*
T & operator*()
Definition: data.h:409
xgboost::DMatrix
Internal data structured used by XGBoost during training.
Definition: data.h:449
xgboost::MetaInfo::LoadBinary
void LoadBinary(dmlc::Stream *fi)
Load the Meta info from binary stream.
XGDMatrixCallbackNext
XGB_EXTERN_C typedef int XGDMatrixCallbackNext(DataIterHandle iter)
Callback function prototype for getting next batch of data.
xgboost::DataType::kDouble
@ kDouble
xgboost::MetaInfo::feature_names
std::vector< std::string > feature_names
Name for each feature.
Definition: data.h:87
xgboost::DataType::kUInt32
@ kUInt32
xgboost::MetaInfo::Extend
void Extend(MetaInfo const &that, bool accumulate_rows)
xgboost::bst_ulong
uint64_t bst_ulong
unsigned long integers
Definition: base.h:117
xgboost::BatchParam::gpu_page_size
size_t gpu_page_size
Page size for external memory mode.
Definition: data.h:215
xgboost::HostSparsePageView::offset
common::Span< bst_row_t const > offset
Definition: data.h:228
xgboost::bst_feature_t
uint32_t bst_feature_t
Type for data column (feature) index.
Definition: base.h:123
xgboost::DMatrix::GetSortedColumnBatches
virtual BatchSet< SortedCSCPage > GetSortedColumnBatches()=0
xgboost::HostSparsePageView::operator[]
Inst operator[](size_t i) const
Definition: data.h:231
xgboost::bst_omp_uint
dmlc::omp_uint bst_omp_uint
define unsigned int for openmp loop
Definition: base.h:270
xgboost::DMatrix::DMatrix
DMatrix()=default
default constructor
xgboost::HostDeviceVector::HostVector
std::vector< T > & HostVector()
DataIterResetCallback
XGB_EXTERN_C typedef void DataIterResetCallback(DataIterHandle handle)
Callback function prototype for reseting external iterator.
xgboost::BatchParam::gpu_id
int gpu_id
The GPU device to use.
Definition: data.h:211
xgboost::MetaInfo::feature_types
HostDeviceVector< FeatureType > feature_types
Definition: data.h:91
span.h
xgboost::DMatrix::EllpackExists
virtual bool EllpackExists() const =0
xgboost::Entry::Entry
XGBOOST_DEVICE Entry(bst_feature_t index, bst_float fvalue)
constructor with index and value
Definition: data.h:196
xgboost::EllpackPage::~EllpackPage
~EllpackPage()
Destructor.
xgboost::DMatrix::IsDense
bool IsDense() const
Whether the matrix is dense.
Definition: data.h:483
xgboost::SortedCSCPage
Definition: data.h:339
xgboost::Entry::operator==
bool operator==(const Entry &other) const
Definition: data.h:201
xgboost::BatchIterator::operator!=
bool operator!=(const BatchIterator &) const
Definition: data.h:419
dmlc::serializer::Handler< xgboost::Entry >::Write
static void Write(Stream *strm, const xgboost::Entry &data)
Definition: data.h:599
xgboost::MetaInfo::GetWeight
bst_float GetWeight(size_t i) const
Get weight of each instances.
Definition: data.h:115
xgboost::HostSparsePageView::Size
size_t Size() const
Definition: data.h:237
xgboost::SparsePage::GetView
HostSparsePageView GetView() const
Definition: data.h:255
xgboost::BatchParam
Parameters for constructing batches.
Definition: data.h:209
xgboost::SparsePage::base_rowid
size_t base_rowid
Definition: data.h:250
xgboost::HostSparsePageView
Definition: data.h:225
xgboost::DataType
DataType
data type accepted by xgboost interface
Definition: data.h:29
xgboost::DMatrix::SparsePageExists
virtual bool SparsePageExists() const =0
xgboost::DMatrix::Create
static DMatrix * Create(AdapterT *adapter, float missing, int nthread, const std::string &cache_prefix="", size_t page_size=kPageSize)
Creates a new DMatrix from an external data adapter.
xgboost::FeatureType::kNumerical
@ kNumerical
xgboost::DMatrix::kPageSize
static const size_t kPageSize
Number of rows per page in external memory. Approximately 100MB per page for dataset with 100 feature...
Definition: data.h:549
xgboost::SparsePage::MemCostBytes
size_t MemCostBytes() const
Definition: data.h:271
XGBOOST_PARALLEL_SORT
#define XGBOOST_PARALLEL_SORT(X, Y, Z)
Definition: base.h:68
xgboost::SparsePage::PushCSC
void PushCSC(const SparsePage &batch)
Push a SparsePage stored in CSC format.
xgboost::MetaInfo::Validate
void Validate(int32_t device) const
Validate all metainfo.
xgboost::SparsePage::GetTranspose
SparsePage GetTranspose(int num_columns) const
xgboost::EllpackPage::Impl
EllpackPageImpl * Impl()
Definition: data.h:382
xgboost::MetaInfo::feature_weigths
HostDeviceVector< float > feature_weigths
Definition: data.h:96
xgboost::HostDeviceVector::Size
size_t Size() const
xgboost::BatchIteratorImpl::operator*
virtual T & operator*()=0
xgboost::FeatureType
FeatureType
Definition: data.h:37
xgboost::CSCPage
Definition: data.h:333
xgboost::Entry::Entry
Entry()=default
default constructor
xgboost::BatchIteratorImpl::AtEnd
virtual bool AtEnd() const =0
xgboost::BatchSet::end
BatchIterator< T > end()
Definition: data.h:438
xgboost::DataType::kStr
@ kStr
xgboost::DMatrix::GetColumnBatches
virtual BatchSet< CSCPage > GetColumnBatches()=0
xgboost::MetaInfo::weights_
HostDeviceVector< bst_float > weights_
weights of each instance, optional
Definition: data.h:64
xgboost::EllpackPage::EllpackPage
EllpackPage()
Default constructor.
xgboost::MetaInfo::num_nonzero_
uint64_t num_nonzero_
number of nonzero entries in the data
Definition: data.h:55
xgboost::XGBAPIThreadLocalEntry
entry to to easily hold returning information
Definition: learner.h:44
xgboost::DataType::kFloat32
@ kFloat32
xgboost::DMatrix::Slice
virtual DMatrix * Slice(common::Span< int32_t const > ridxs)=0
xgboost::common::Span
span class implementation, based on ISO++20 span<T>. The interface should be the same.
Definition: span.h:142
xgboost::DMatrix::Load
static DMatrix * Load(const std::string &uri, bool silent, bool load_row_split, const std::string &file_format="auto", size_t page_size=kPageSize)
Load DMatrix from URI.
std
Definition: intrusive_ptr.h:206
xgboost::BatchParam::BatchParam
BatchParam(int32_t device, int32_t max_bin, size_t gpu_page_size=0)
Definition: data.h:217
xgboost::MetaInfo::operator=
MetaInfo & operator=(MetaInfo &&that)=default
xgboost::MetaInfo::SaveBinary
void SaveBinary(dmlc::Stream *fo) const
Save the Meta info to binary stream.
xgboost::SparsePage::offset
HostDeviceVector< bst_row_t > offset
Definition: data.h:246
xgboost::MetaInfo::GetInfo
void GetInfo(char const *key, bst_ulong *out_len, DataType dtype, const void **out_dptr) const
DMatrixHandle
void * DMatrixHandle
handle to DMatrix
Definition: c_api.h:30
xgboost::common::Span::size
constexpr XGBOOST_DEVICE index_type size() const __span_noexcept
Definition: span.h:547
xgboost::BatchIterator
Definition: data.h:399
xgboost::common::Span::data
constexpr XGBOOST_DEVICE pointer data() const __span_noexcept
Definition: span.h:542
xgboost::Entry::CmpValue
static bool CmpValue(const Entry &a, const Entry &b)
reversely compare feature values
Definition: data.h:198
xgboost::MetaInfo
Meta information about dataset, always sit in memory.
Definition: data.h:45
xgboost::DMatrix::GetThreadLocal
XGBAPIThreadLocalEntry & GetThreadLocal() const
Get thread local memory for returning data from DMatrix.
xgboost::EllpackPage::SetBaseRowId
void SetBaseRowId(size_t row_id)
Set the base row id for this page.
dmlc::DMLC_DECLARE_TRAITS
DMLC_DECLARE_TRAITS(is_pod, xgboost::Entry, true)
xgboost::Entry::fvalue
bst_float fvalue
feature value
Definition: data.h:188
xgboost::DMatrix::GetBatches
BatchSet< T > GetBatches(const BatchParam &param={})
Gets batches. Use range based for loop over BatchSet to access individual batches.
xgboost::MetaInfo::labels_
HostDeviceVector< bst_float > labels_
label of each instance
Definition: data.h:57
xgboost::FeatureType::kCategorical
@ kCategorical
XGBOOST_DEVICE
#define XGBOOST_DEVICE
Tag function as usable by device.
Definition: base.h:84
xgboost::DMatrix::SetInfo
virtual void SetInfo(const char *key, const void *dptr, DataType dtype, size_t num)
Definition: data.h:455
xgboost::DMatrix::PageExists
bool PageExists() const
xgboost::SparsePage::data
HostDeviceVector< Entry > data
the data of the segments
Definition: data.h:248
dmlc::serializer::Handler< xgboost::Entry >::Read
static bool Read(Stream *strm, xgboost::Entry *data)
Definition: data.h:604
xgboost::BatchIterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: data.h:401
xgboost::MetaInfo::kNumField
static constexpr uint64_t kNumField
number of data fields in MetaInfo
Definition: data.h:48
xgboost::BatchSet
Definition: data.h:434
xgboost
namespace of xgboost
Definition: base.h:110
xgboost::SparsePage::Clear
void Clear()
clear the page
Definition: data.h:276
xgboost::MetaInfo::labels_upper_bound_
HostDeviceVector< bst_float > labels_upper_bound_
upper bound of the label, to be used for survival analysis (censored regression)
Definition: data.h:78
xgboost::bst_float
float bst_float
float type, used for storing statistics
Definition: base.h:119
xgboost::SparsePage::SparsePage
SparsePage()
constructor
Definition: data.h:261