gators.model_building.XGBTreeliteDumper

class gators.model_building.XGBTreeliteDumper[source]

XGBoost Treelite Dumper class.

Examples

>>> import numpy as np
>>> import xgboost as xgb
>>> from gators.model_building import XGBTreeliteDumper
>>> X_train = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
>>> y_train = np.array([0, 1, 1, 0])
>>> dtrain = xgb.DMatrix(X_train, label=y_train)
>>> model = xgb.train({'max_depth': 1}, dtrain, num_boost_round=1)
>>> XGBTreeliteDumper.dump(
... model=model,
... toolchain='gcc',
... parallel_comp=1,
... model_path='.',
... model_name='dummy')
[00:00:00] /Users/travis/build/dmlc/treelite/src/compiler/ast/split.cc:29: Parallel compilation enabled; member trees will be divided into 1 translation units.
[00:00:01] /Users/travis/build/dmlc/treelite/src/compiler/ast/split.cc:29: Parallel compilation enabled; member trees will be divided into 1 translation units.
static dump(model: xgboost.core.Booster, toolchain: str, parallel_comp: int, model_path: str, model_name: str, verbose: bool = False)[source]

Dump the XGBoost treelite as a .so and a .dylib file.

Parameters
model: xgboost.core.Booster.

Trained model.

toolchain: str

Compiler. List of available treelite compiler. * gcc * clang * msvc

parallel_comp: int

Treelite parallel compilation.

model_pathstr

Model path.

model_namestr

Model name.

verbose: bool, default False.

Verbosity.