### Install TL2cgen using pip Source: https://tl2cgen.readthedocs.io Install TL2cgen using pip. This is the standard method for installing Python packages. ```bash pip install tl2cgen ``` -------------------------------- ### Install TL2cgen using Conda Source: https://tl2cgen.readthedocs.io Install TL2cgen from the conda-forge channel. This is an alternative installation method for Conda users. ```bash conda install -c conda-forge tl2cgen ``` -------------------------------- ### Import and Load Tree Model with Treelite Source: https://tl2cgen.readthedocs.io Import the treelite library and load a tree ensemble model from a JSON file. Ensure the model file exists and the format is correctly specified. ```python import treelite # Used for importing tree model model = treelite.Model.load("my_model.json", model_format="xgboost_json") ``` -------------------------------- ### Make Predictions with Native Library Source: https://tl2cgen.readthedocs.io Load the exported native shared library using the Predictor class and make predictions on new data. The data should be in a DMatrix format. ```python predictor = tl2cgen.Predictor("./predictor.so") dmat = tl2cgen.DMatrix(X) out_pred = predictor.predict(dmat) ``` -------------------------------- ### Export Source Archive with CMakeLists.txt Source: https://tl2cgen.readthedocs.io Export a source archive containing the compiled code and a CMakeLists.txt file for building. This is useful for cross-platform compilation or when direct library export is not feasible. ```python # Run `cmake` on the target machine tl2cgen.export_srcpkg(model, toolchain="cmake", pkgpath="./archive.zip", libname="predictor") ``` -------------------------------- ### Generate C Code with TL2cgen Source: https://tl2cgen.readthedocs.io Use TL2cgen to generate C code from a loaded Treelite model. The generated code will be saved to the specified directory. ```python import tl2cgen tl2cgen.generate_c_code(model, dirpath="./src") ``` -------------------------------- ### Export Native Shared Library with TL2cgen Source: https://tl2cgen.readthedocs.io Export the compiled model as a native shared library. Specify the toolchain (e.g., 'gcc') and the desired output path for the library. ```python tl2cgen.export_lib(model, toolchain="gcc", libpath="./predictor.so") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.