It would be great to have a tutorial for using the C API of XGBoost in a C or C++ application. Some important components:
XGBGetLastError()
.Note to new contributors: Post a comment here if you'd like to work on this issue. Feel free to ping me for help.
@hcho3 hello, sir
I'm efficient in C++ and would like to work on this? I will update you as soon as possible. How I can connect with you for help & guidance( like slack/discord/discourse/ or the discussion forum of XGBoost)? I've read the contributing guidelines & coding guidlines in C++ provided in the XGBoost documentation. Could you please assign it to me? I've started working on it.
@divya661 Thanks for volunteering. You have two options:
@hcho3 Sir, could you please suggest me a few resources regarding the first 2 points of this issue?
@divya661 Take a look at https://github.com/dmlc/xgboost/blob/6bc41df2fefe5a1205f75d6b9bfd4d331f0d025f/.github/workflows/main.yml#L62-L78, which is an automated script to test the C API example (https://github.com/dmlc/xgboost/blob/master/demo/c-api/c-api-demo.c).
@hcho3 in point 2, by "system prefix" you mean with different OS like Windows, Mac OS & others? (want to confirm)
@divya661 No, the prefix refers to a directory where a package is to be installed. The term is used in GNU Autotools, e.g. https://www.gnu.org/prep/standards/html_node/Directory-Variables.html. The system prefix on Linux is /usr/local
. It's called "system" prefix because the prefix is set system-wide.
Since writing to /usr/local
requires the administrative privilege, it is often convenient to install a package into another prefix directory that is different from the system prefix (/usr/local
). Creating a Conda environment creates a new prefix directory inside the user's home directory (usually $HOME/miniconda3/envs/[env_name]
). Since this prefix is inside the home directory, the user is able to install packages into it without needing a permission from the administrator.
@divya661 Any updates? If you'd like further assistance, please do let me know.
@hcho3 I'll try to finish it in the coming next 2-3 days & submit my PR, sir. I apologize for the long delay, as I got busy with some urgent work.
@divya661 Thanks for the update. No need to apologize, as we all have our responsibilities. Do let me know if you need assistance.
@hcho3 Sir, I think this file https://github.com/dmlc/xgboost/blob/master/demo/c-api/README.md tells about configuring the cmakelist.txt file to link xgboost with external C/C++ application. Do I need to extend it for static & dynamic linking?
@divya661 My suggestion is to add a tutorial in the directory https://github.com/dmlc/xgboost/tree/master/doc/tutorials. To render the docs, go to the doc
directory and run:
# Create Conda environment, with necessary Python packages.
# You need to do this only once
conda env create -n docgen --file=./xgboost_doc.yml
# Now activate the environment, to access the Python package
conda activate docgen
# This command will use Sphinx package to generate the docs.
make html
@hcho3 In the tutorial, should I also provide small examples to use various functions available in C API other than useful tips?
Yes that would be great.
@hcho3 Sir, could you please give me more hints on useful tips (other than exception handling using XGBGetLastError()
& cleaning up Xgboost object handles
) to work on, I have currently implemented only these two in my draft?
For now, you should submit a pull request with what you have. We can always add more material later.
Addressed in #6285