Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions
xgboost::DMatrix Class Referenceabstract

Internal data structured used by XGBoost during training. More...

#include <data.h>

Public Member Functions

 DMatrix ()=default
 default constructor
 
virtual MetaInfoInfo ()=0
 meta information of the dataset
 
virtual void SetInfo (const char *key, const void *dptr, DataType dtype, size_t num)
 
virtual void SetInfo (const char *key, std::string const &interface_str)
 
virtual const MetaInfoInfo () const =0
 meta information of the dataset
 
XGBAPIThreadLocalEntryGetThreadLocal () const
 Get thread local memory for returning data from DMatrix.
 
virtual Context const * Ctx () const =0
 Get the context object of this DMatrix.
 
template<typename T >
BatchSet< T > GetBatches ()
 Gets batches.
 
template<typename T >
BatchSet< T > GetBatches (Context const *ctx)
 
template<typename T >
BatchSet< T > GetBatches (Context const *ctx, const BatchParam &param)
 
template<typename T >
bool PageExists () const
 
virtual bool SingleColBlock () const =0
 
virtual ~DMatrix ()
 virtual destructor
 
bool IsDense () const
 Whether the matrix is dense.
 
virtual DMatrixSlice (common::Span< int32_t const > ridxs)=0
 
virtual DMatrixSliceCol (int num_slices, int slice_id)=0
 Slice a DMatrix by columns.
 
template<>
BatchSet< SparsePageGetBatches ()
 
template<>
bool PageExists () const
 
template<>
bool PageExists () const
 
template<>
bool PageExists () const
 
template<>
BatchSet< SparsePageGetBatches (Context const *)
 
template<>
BatchSet< CSCPageGetBatches (Context const *ctx)
 
template<>
BatchSet< SortedCSCPageGetBatches (Context const *ctx)
 
template<>
BatchSet< EllpackPageGetBatches (Context const *ctx, BatchParam const &param)
 
template<>
BatchSet< GHistIndexMatrixGetBatches (Context const *ctx, BatchParam const &param)
 
template<>
BatchSet< ExtSparsePageGetBatches (Context const *ctx, BatchParam const &param)
 

Static Public Member Functions

static DMatrixLoad (const std::string &uri, bool silent=true, DataSplitMode data_split_mode=DataSplitMode::kRow)
 Load DMatrix from URI.
 
template<typename AdapterT >
static DMatrixCreate (AdapterT *adapter, float missing, int nthread, const std::string &cache_prefix="", DataSplitMode data_split_mode=DataSplitMode::kRow)
 Creates a new DMatrix from an external data adapter.
 
template<typename DataIterHandle , typename DMatrixHandle , typename DataIterResetCallback , typename XGDMatrixCallbackNext >
static DMatrixCreate (DataIterHandle iter, DMatrixHandle proxy, std::shared_ptr< DMatrix > ref, DataIterResetCallback *reset, XGDMatrixCallbackNext *next, float missing, int nthread, bst_bin_t max_bin)
 Create a new Quantile based DMatrix used for histogram based algorithm.
 
template<typename DataIterHandle , typename DMatrixHandle , typename DataIterResetCallback , typename XGDMatrixCallbackNext >
static DMatrixCreate (DataIterHandle iter, DMatrixHandle proxy, DataIterResetCallback *reset, XGDMatrixCallbackNext *next, float missing, int32_t nthread, std::string cache)
 Create an external memory DMatrix with callbacks.
 

Protected Member Functions

virtual BatchSet< SparsePageGetRowBatches ()=0
 
virtual BatchSet< CSCPageGetColumnBatches (Context const *ctx)=0
 
virtual BatchSet< SortedCSCPageGetSortedColumnBatches (Context const *ctx)=0
 
virtual BatchSet< EllpackPageGetEllpackBatches (Context const *ctx, BatchParam const &param)=0
 
virtual BatchSet< GHistIndexMatrixGetGradientIndex (Context const *ctx, BatchParam const &param)=0
 
virtual BatchSet< ExtSparsePageGetExtBatches (Context const *ctx, BatchParam const &param)=0
 
virtual bool EllpackExists () const =0
 
virtual bool GHistIndexExists () const =0
 
virtual bool SparsePageExists () const =0
 

Detailed Description

Internal data structured used by XGBoost during training.

Member Function Documentation

◆ Create() [1/3]

template<typename AdapterT >
DMatrix * xgboost::DMatrix::Create ( AdapterT *  adapter,
float  missing,
int  nthread,
const std::string &  cache_prefix = "",
DataSplitMode  data_split_mode = DataSplitMode::kRow 
)
static

Creates a new DMatrix from an external data adapter.

Template Parameters
AdapterTType of the adapter.
Parameters
[in,out]adapterView onto an external data.
missingValues to count as missing.
nthreadNumber of threads for construction.
cache_prefix(Optional) The cache prefix for external memory.
data_split_mode(Optional) Data split mode.
Returns
a Created DMatrix.

◆ Create() [2/3]

template<typename DataIterHandle , typename DMatrixHandle , typename DataIterResetCallback , typename XGDMatrixCallbackNext >
DMatrix * xgboost::DMatrix::Create ( DataIterHandle  iter,
DMatrixHandle  proxy,
DataIterResetCallback reset,
XGDMatrixCallbackNext next,
float  missing,
int32_t  nthread,
std::string  cache 
)
static

Create an external memory DMatrix with callbacks.

Template Parameters
DataIterHandleExternal iterator type, defined in C API.
DMatrixHandleDMatrix handle, defined in C API.
DataIterResetCallbackCallback for reset, prototype defined in C API.
XGDMatrixCallbackNextCallback for next, prototype defined in C API.
Parameters
iterExternal data iterator
proxyA hanlde to ProxyDMatrix
resetCallback for reset
nextCallback for next
missingValue that should be treated as missing.
nthreadnumber of threads used for initialization.
cachePrefix of cache file path.
Returns
A created external memory DMatrix.

◆ Create() [3/3]

template<typename DataIterHandle , typename DMatrixHandle , typename DataIterResetCallback , typename XGDMatrixCallbackNext >
DMatrix * xgboost::DMatrix::Create ( DataIterHandle  iter,
DMatrixHandle  proxy,
std::shared_ptr< DMatrix ref,
DataIterResetCallback reset,
XGDMatrixCallbackNext next,
float  missing,
int  nthread,
bst_bin_t  max_bin 
)
static

Create a new Quantile based DMatrix used for histogram based algorithm.

Template Parameters
DataIterHandleExternal iterator type, defined in C API.
DMatrixHandleDMatrix handle, defined in C API.
DataIterResetCallbackCallback for reset, prototype defined in C API.
XGDMatrixCallbackNextCallback for next, prototype defined in C API.
Parameters
iterExternal data iterator
proxyA hanlde to ProxyDMatrix
refReference Quantile DMatrix.
resetCallback for reset
nextCallback for next
missingValue that should be treated as missing.
nthreadnumber of threads used for initialization.
max_binMaximum number of bins.
Returns
A created quantile based DMatrix.

◆ Ctx()

virtual Context const * xgboost::DMatrix::Ctx ( ) const
pure virtual

Get the context object of this DMatrix.

The context is created during construction of DMatrix with user specified nthread parameter.

◆ GetBatches()

template<typename T >
BatchSet< T > xgboost::DMatrix::GetBatches ( )

Gets batches.

Use range based for loop over BatchSet to access individual batches.

◆ Load()

DMatrix * xgboost::DMatrix::Load ( const std::string &  uri,
bool  silent = true,
DataSplitMode  data_split_mode = DataSplitMode::kRow 
)
static

Load DMatrix from URI.

Parameters
uriThe URI of input.
silentWhether print information during loading.
data_split_modeIn distributed mode, split the input according this mode; otherwise, it's just an indicator on how the input was split beforehand.
Returns
The created DMatrix.

◆ SingleColBlock()

virtual bool xgboost::DMatrix::SingleColBlock ( ) const
pure virtual
Returns
Whether the data columns single column block.

◆ SliceCol()

virtual DMatrix * xgboost::DMatrix::SliceCol ( int  num_slices,
int  slice_id 
)
pure virtual

Slice a DMatrix by columns.

Parameters
num_slicesTotal number of slices
slice_idIndex of the current slice
Returns
DMatrix containing the slice of columns

The documentation for this class was generated from the following files: