Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Protected Attributes
LightGBM::Dense4bitsBin Class Reference
Inheritance diagram for LightGBM::Dense4bitsBin:
LightGBM::Bin

Public Member Functions

 Dense4bitsBin (data_size_t num_data)
 
void Push (int, data_size_t idx, uint32_t value) override
 Push one record \pram tid Thread id.
 
void ReSize (data_size_t num_data) override
 
BinIteratorGetIterator (uint32_t min_bin, uint32_t max_bin, uint32_t default_bin) const override
 Get bin iterator of this bin for specific feature.
 
void ConstructHistogram (const data_size_t *data_indices, data_size_t num_data, const score_t *ordered_gradients, const score_t *ordered_hessians, HistogramBinEntry *out) const override
 Construct histogram of this feature, Note: We use ordered_gradients and ordered_hessians to improve cache hit chance The naive solution is using gradients[data_indices[i]] for data_indices[i] to get gradients, which is not cache friendly, since the access of memory is not continuous. ordered_gradients and ordered_hessians are preprocessed, and they are re-ordered by data_indices. Ordered_gradients[i] is aligned with data_indices[i]'s gradients (same for ordered_hessians).
 
void ConstructHistogram (data_size_t num_data, const score_t *ordered_gradients, const score_t *ordered_hessians, HistogramBinEntry *out) const override
 
void ConstructHistogram (const data_size_t *data_indices, data_size_t num_data, const score_t *ordered_gradients, HistogramBinEntry *out) const override
 Construct histogram of this feature, Note: We use ordered_gradients and ordered_hessians to improve cache hit chance The naive solution is using gradients[data_indices[i]] for data_indices[i] to get gradients, which is not cache friendly, since the access of memory is not continuous. ordered_gradients and ordered_hessians are preprocessed, and they are re-ordered by data_indices. Ordered_gradients[i] is aligned with data_indices[i]'s gradients (same for ordered_hessians).
 
void ConstructHistogram (data_size_t num_data, const score_t *ordered_gradients, HistogramBinEntry *out) const override
 
virtual data_size_t Split (uint32_t min_bin, uint32_t max_bin, uint32_t default_bin, MissingType missing_type, bool default_left, uint32_t threshold, data_size_t *data_indices, data_size_t num_data, data_size_t *lte_indices, data_size_t *gt_indices) const override
 Split data according to threshold, if bin <= threshold, will put into left(lte_indices), else put into right(gt_indices)
 
virtual data_size_t SplitCategorical (uint32_t min_bin, uint32_t max_bin, uint32_t default_bin, const uint32_t *threshold, int num_threahold, data_size_t *data_indices, data_size_t num_data, data_size_t *lte_indices, data_size_t *gt_indices) const override
 Split data according to threshold, if bin <= threshold, will put into left(lte_indices), else put into right(gt_indices)
 
data_size_t num_data () const override
 Number of all data.
 
OrderedBinCreateOrderedBin () const override
 not ordered bin for dense feature
 
void FinishLoad () override
 After pushed all feature data, call this could have better refactor for bin data.
 
void LoadFromMemory (const void *memory, const std::vector< data_size_t > &local_used_indices) override
 Load from memory.
 
void CopySubset (const Bin *full_bin, const data_size_t *used_indices, data_size_t num_used_indices) override
 
void SaveBinaryToFile (const VirtualFileWriter *writer) const override
 Save binary data to file.
 
size_t SizesInByte () const override
 Get sizes in byte of this object.
 
- Public Member Functions inherited from LightGBM::Bin
virtual ~Bin ()
 virtual destructor
 

Data Fields

friend Dense4bitsBinIterator
 

Protected Attributes

data_size_t num_data_
 
std::vector< uint8_t > data_
 
std::vector< uint8_t > buf_
 

Additional Inherited Members

- Static Public Member Functions inherited from LightGBM::Bin
static BinCreateBin (data_size_t num_data, int num_bin, double sparse_rate, bool is_enable_sparse, double sparse_threshold, bool *is_sparse)
 Create object for bin data of one feature, will call CreateDenseBin or CreateSparseBin according to "is_sparse".
 
static BinCreateDenseBin (data_size_t num_data, int num_bin)
 Create object for bin data of one feature, used for dense feature.
 
static BinCreateSparseBin (data_size_t num_data, int num_bin)
 Create object for bin data of one feature, used for sparse feature.
 

Member Function Documentation

◆ ConstructHistogram() [1/4]

void LightGBM::Dense4bitsBin::ConstructHistogram ( const data_size_t data_indices,
data_size_t  num_data,
const score_t ordered_gradients,
const score_t ordered_hessians,
HistogramBinEntry out 
) const
inlineoverridevirtual

Construct histogram of this feature, Note: We use ordered_gradients and ordered_hessians to improve cache hit chance The naive solution is using gradients[data_indices[i]] for data_indices[i] to get gradients, which is not cache friendly, since the access of memory is not continuous. ordered_gradients and ordered_hessians are preprocessed, and they are re-ordered by data_indices. Ordered_gradients[i] is aligned with data_indices[i]'s gradients (same for ordered_hessians).

Parameters
data_indicesUsed data indices in current leaf
num_dataNumber of used data
ordered_gradientsPointer to gradients, the data_indices[i]-th data's gradient is ordered_gradients[i]
ordered_hessiansPointer to hessians, the data_indices[i]-th data's hessian is ordered_hessians[i]
outOutput Result

Implements LightGBM::Bin.

◆ ConstructHistogram() [2/4]

void LightGBM::Dense4bitsBin::ConstructHistogram ( const data_size_t data_indices,
data_size_t  num_data,
const score_t ordered_gradients,
HistogramBinEntry out 
) const
inlineoverridevirtual

Construct histogram of this feature, Note: We use ordered_gradients and ordered_hessians to improve cache hit chance The naive solution is using gradients[data_indices[i]] for data_indices[i] to get gradients, which is not cache friendly, since the access of memory is not continuous. ordered_gradients and ordered_hessians are preprocessed, and they are re-ordered by data_indices. Ordered_gradients[i] is aligned with data_indices[i]'s gradients (same for ordered_hessians).

Parameters
data_indicesUsed data indices in current leaf
num_dataNumber of used data
ordered_gradientsPointer to gradients, the data_indices[i]-th data's gradient is ordered_gradients[i]
outOutput Result

Implements LightGBM::Bin.

◆ ConstructHistogram() [3/4]

void LightGBM::Dense4bitsBin::ConstructHistogram ( data_size_t  num_data,
const score_t ordered_gradients,
const score_t ordered_hessians,
HistogramBinEntry out 
) const
inlineoverridevirtual

Implements LightGBM::Bin.

◆ ConstructHistogram() [4/4]

void LightGBM::Dense4bitsBin::ConstructHistogram ( data_size_t  num_data,
const score_t ordered_gradients,
HistogramBinEntry out 
) const
inlineoverridevirtual

Implements LightGBM::Bin.

◆ CopySubset()

void LightGBM::Dense4bitsBin::CopySubset ( const Bin full_bin,
const data_size_t used_indices,
data_size_t  num_used_indices 
)
inlineoverridevirtual

Implements LightGBM::Bin.

◆ CreateOrderedBin()

OrderedBin * LightGBM::Dense4bitsBin::CreateOrderedBin ( ) const
inlineoverridevirtual

not ordered bin for dense feature

Implements LightGBM::Bin.

◆ FinishLoad()

void LightGBM::Dense4bitsBin::FinishLoad ( )
inlineoverridevirtual

After pushed all feature data, call this could have better refactor for bin data.

Implements LightGBM::Bin.

◆ GetIterator()

BinIterator * LightGBM::Dense4bitsBin::GetIterator ( uint32_t  min_bin,
uint32_t  max_bin,
uint32_t  default_bin 
) const
inlineoverridevirtual

Get bin iterator of this bin for specific feature.

Parameters
min_binmin_bin of current used feature
max_binmax_bin of current used feature
default_bindefault bin if bin not in [min_bin, max_bin]
Returns
Iterator of this bin

Implements LightGBM::Bin.

◆ LoadFromMemory()

void LightGBM::Dense4bitsBin::LoadFromMemory ( const void *  memory,
const std::vector< data_size_t > &  local_used_indices 
)
inlineoverridevirtual

Load from memory.

Parameters
memory
local_used_indices

Implements LightGBM::Bin.

◆ num_data()

data_size_t LightGBM::Dense4bitsBin::num_data ( ) const
inlineoverridevirtual

Number of all data.

Implements LightGBM::Bin.

◆ Push()

void LightGBM::Dense4bitsBin::Push ( int  tid,
data_size_t  idx,
uint32_t  value 
)
inlineoverridevirtual

Push one record \pram tid Thread id.

Parameters
idxIndex of record
valuebin value of record

Implements LightGBM::Bin.

◆ ReSize()

void LightGBM::Dense4bitsBin::ReSize ( data_size_t  num_data)
inlineoverridevirtual

Implements LightGBM::Bin.

◆ SaveBinaryToFile()

void LightGBM::Dense4bitsBin::SaveBinaryToFile ( const VirtualFileWriter writer) const
inlineoverridevirtual

Save binary data to file.

Parameters
fileFile want to write

Implements LightGBM::Bin.

◆ SizesInByte()

size_t LightGBM::Dense4bitsBin::SizesInByte ( ) const
inlineoverridevirtual

Get sizes in byte of this object.

Implements LightGBM::Bin.

◆ Split()

virtual data_size_t LightGBM::Dense4bitsBin::Split ( uint32_t  min_bin,
uint32_t  max_bin,
uint32_t  default_bin,
MissingType  missing_type,
bool  default_left,
uint32_t  threshold,
data_size_t data_indices,
data_size_t  num_data,
data_size_t lte_indices,
data_size_t gt_indices 
) const
inlineoverridevirtual

Split data according to threshold, if bin <= threshold, will put into left(lte_indices), else put into right(gt_indices)

Parameters
min_binmin_bin of current used feature
max_binmax_bin of current used feature
default_bindefualt bin if bin not in [min_bin, max_bin]
missing_typemissing type
default_leftmissing bin will go to left child
thresholdThe split threshold.
data_indicesUsed data indices. After called this function. The less than or equal data indices will store on this object.
num_dataNumber of used data
lte_indicesAfter called this function. The less or equal data indices will store on this object.
gt_indicesAfter called this function. The greater data indices will store on this object.
Returns
The number of less than or equal data.

Implements LightGBM::Bin.

◆ SplitCategorical()

virtual data_size_t LightGBM::Dense4bitsBin::SplitCategorical ( uint32_t  min_bin,
uint32_t  max_bin,
uint32_t  default_bin,
const uint32_t *  threshold,
int  num_threshold,
data_size_t data_indices,
data_size_t  num_data,
data_size_t lte_indices,
data_size_t gt_indices 
) const
inlineoverridevirtual

Split data according to threshold, if bin <= threshold, will put into left(lte_indices), else put into right(gt_indices)

Parameters
min_binmin_bin of current used feature
max_binmax_bin of current used feature
default_bindefualt bin if bin not in [min_bin, max_bin]
thresholdThe split threshold.
num_thresholdNumber of threshold
data_indicesUsed data indices. After called this function. The less than or equal data indices will store on this object.
num_dataNumber of used data
lte_indicesAfter called this function. The less or equal data indices will store on this object.
gt_indicesAfter called this function. The greater data indices will store on this object.
Returns
The number of less than or equal data.

Implements LightGBM::Bin.


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