Description
openedon May 26, 2021
Relevant only when #4089 is merged.
Summary
Find a way to keep constants in Python package in sync with C++ library.
This is needed in order to keep python package behaves the same as the cmdline version.
Motivation
#4089 handles data sampling in Python. It defines 2 constant variables ZERO_THRESHOLD
and DEFAULT_BIN_CONSTRUCT_SAMPLE_CNT
.
Currently they are set to the same value as in C++. If the default value changs in C++ side, we have to manually change them in Python side.
Description
I suggest we expose relevant constants in C API and use them in other language packages.
We can define a map which contains constant name and their value. Then add a C API to get those values, e.g.
const char* LGBM_GetConstant(const char* key);
References
Relevant code in #4089
Constants defined in pyhon package.
https://github.com/cyfdecyf/LightGBM/blob/f86d2db89d89810ddac0bc842af8d392a47edc85/python-package/lightgbm/basic.py#L21-L22
Usage:
https://github.com/cyfdecyf/LightGBM/blob/f86d2db89d89810ddac0bc842af8d392a47edc85/python-package/lightgbm/basic.py#L1556
https://github.com/cyfdecyf/LightGBM/blob/f86d2db89d89810ddac0bc842af8d392a47edc85/python-package/lightgbm/basic.py#L1217
https://github.com/cyfdecyf/LightGBM/blob/f86d2db89d89810ddac0bc842af8d392a47edc85/python-package/lightgbm/basic.py#L1580