xgboost

Public Member Functions | List of all members
xgboost::common::ColumnSampler Class Reference

Handles selection of columns due to colsample_bytree, colsample_bylevel and colsample_bynode parameters. Should be initialised before tree construction and to reset when tree construction is completed. More...

`#include <random.h>`

Collaboration diagram for xgboost::common::ColumnSampler:

## Public Member Functions
std::shared_ptr< HostDeviceVector< bst_feature_t > > | ColSample (std::shared_ptr< HostDeviceVector< bst_feature_t >> p_features, float colsample)
| ColumnSampler (uint32_t seed)
| Column sampler constructor. More...
| ColumnSampler ()
| Column sampler constructor. More...
void | Init (int64_t num_col, std::vector< float > feature_weights, float colsample_bynode, float colsample_bylevel, float colsample_bytree, bool skip_index_0=false)
| Initialise this object before use. More...
void | Reset ()
| Resets this object. More...
std::shared_ptr< HostDeviceVector< bst_feature_t > > | GetFeatureSet (int depth)
| Samples a feature set. More...

## Detailed Description

Handles selection of columns due to colsample_bytree, colsample_bylevel and colsample_bynode parameters. Should be initialised before tree construction and to reset when tree construction is completed.

## Constructor & Destructor Documentation

## ◆ ColumnSampler() [1/2]

xgboost::common::ColumnSampler::ColumnSampler | ( | uint32_t | seed | ) |
| inline explicit

Column sampler constructor.

Note
  This constructor manually sets the rng seed

## ◆ ColumnSampler() [2/2]

xgboost::common::ColumnSampler::ColumnSampler | ( |  | ) |
| inline

Column sampler constructor.

Note
  This constructor synchronizes the RNG seed across processes.

## Member Function Documentation

## ◆ ColSample()

std::shared_ptr<HostDeviceVector<bst_feature_t> > xgboost::common::ColumnSampler::ColSample | ( | std::shared_ptr< HostDeviceVector< bst_feature_t >> | p_features,
|  | float | colsample
| ) |  |

## ◆ GetFeatureSet()

std::shared_ptr<HostDeviceVector<bst_feature_t> > xgboost::common::ColumnSampler::GetFeatureSet | ( | int | depth | ) |
| inline

Samples a feature set.

Parameters

  depth | The tree depth of the node at which to sample.

Returns
  The sampled feature set.

Note
  If colsample_bynode_ < 1.0, this method creates a new feature set each time it is called. Therefore, it should be called only once per node.
  With distributed xgboost, this function must be called exactly once for the construction of each tree node, and must be called the same number of times in each process and with the same parameters to return the same feature set across processes.

## ◆ Init()

void xgboost::common::ColumnSampler::Init | ( | int64_t | num_col,
|  | std::vector< float > | feature_weights,
|  | float | colsample_bynode,
|  | float | colsample_bylevel,
|  | float | colsample_bytree,
|  | bool | skip_index_0 = `false`
| ) |  |
| inline

Initialise this object before use.

Parameters

  num_col |
  colsample_bynode |
  colsample_bylevel |
  colsample_bytree |
  skip_index_0 | (Optional) True to skip index 0.

## ◆ Reset()

void xgboost::common::ColumnSampler::Reset | ( |  | ) |
| inline

Resets this object.

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

- /home/runner/work/xgboost/xgboost/src/common/random.h