MCPcopy Create free account
hub / github.com/dmlc/xgboost / main

Function main

demo/guide-python/quantile_data_iterator.py:96–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94
95
96def main() -> None:
97 rounds = 100
98 it = IterForDMatrixDemo()
99
100 # Use iterator, must be `QuantileDMatrix`.
101
102 # In this demo, the input batches are created using cupy, and the data processing
103 # (quantile sketching) will be performed on GPU. If data is loaded with CPU based
104 # data structures like numpy or pandas, then the processing step will be performed
105 # on CPU instead.
106 m_with_it = xgboost.QuantileDMatrix(it)
107
108 # Use regular DMatrix.
109 m = xgboost.DMatrix(
110 it.as_array(), it.as_array_labels(), weight=it.as_array_weights()
111 )
112
113 assert m_with_it.num_col() == m.num_col()
114 assert m_with_it.num_row() == m.num_row()
115 # Tree method must be `hist`.
116 reg_with_it = xgboost.train(
117 {"tree_method": "hist", "device": "cuda"},
118 m_with_it,
119 num_boost_round=rounds,
120 evals=[(m_with_it, "Train")],
121 )
122 predict_with_it = reg_with_it.predict(m_with_it)
123
124 reg = xgboost.train(
125 {"tree_method": "hist", "device": "cuda"},
126 m,
127 num_boost_round=rounds,
128 evals=[(m, "Train")],
129 )
130 predict = reg.predict(m)
131
132
133if __name__ == "__main__":

Callers 1

Calls 10

as_arrayMethod · 0.95
as_array_labelsMethod · 0.95
as_array_weightsMethod · 0.95
num_colMethod · 0.95
num_rowMethod · 0.95
IterForDMatrixDemoClass · 0.85
QuantileDMatrixMethod · 0.80
DMatrixMethod · 0.45
trainMethod · 0.45
predictMethod · 0.45

Tested by

no test coverage detected