======== Treelite ======== **Treelite** is a universal model exchange and serialization format for decision tree forests. Treelite aims to be a small library that enables other C++ applications to exchange and store decision trees on the disk as well as the network. .. raw:: html Star Watch .. warning:: Tree compiler was migrated to TL2cgen If you are looking for a compiler to translate tree models into C code, use :doc:`TL2cgen `. To migrate existing code using Treelite 3.x, consult the page :doc:`tl2cgen:treelite-migration`. Why Treelite? ============= Universal, lightweight specification for all tree models -------------------------------------------------------- Are you designing a C++ application that needs to read and write tree models, e.g. a prediction server? Do not be overwhelmed by the variety of tree models in the wild. Treelite lets you convert many kinds of tree models into a **common specification**. By using Treelite as a library, your application now only needs to deal with one model specification instead of many. Treelite currently supports: * `XGBoost `_ * `LightGBM `_ * `scikit-learn `_ * :doc:`flexible builder class ` for users of other tree libraries In addition, tree libraries can directly output trained trees using the Treelite specification. For example, the random forest algoritm in `RAPIDS cuML `_ stores the random forest object using Treelite. .. raw:: html


(Click to enlarge)

A small library that's easy to embed in another C++ application --------------------------------------------------------------- Treelite has an up-to-date CMake build script. If your C++ application uses CMake, it is easy to embed Treelite. Treelite is currently used by the following applications: * :doc:`tl2cgen:index` * Forest Inference Library (FIL) in `RAPIDS cuML `_ * `Triton Inference Server FIL Backend `_, an optimized prediction runtime for CPUs and GPUs. Quick start =========== Install Treelite: .. code-block:: console # From PyPI pip install treelite # From Conda conda install -c conda-forge treelite Import your tree ensemble model into Treelite: .. code-block:: python import treelite model = treelite.frontend.load_xgboost_model("my_model.json") Compute predictions using :doc:`treelite-gtil-api`: .. code-block:: python X = ... # numpy array treelite.gtil.predict(model, data=X) ******** Contents ******** .. toctree:: :maxdepth: 2 :titlesonly: install tutorials/index treelite-api treelite-gtil-api treelite-c-api knobs/index serialization/index treelite-doxygen ******* Indices ******* * :ref:`genindex` * :ref:`modindex`