treelite
model_loader.h
Go to the documentation of this file.
1 
7 #ifndef TREELITE_MODEL_LOADER_H_
8 #define TREELITE_MODEL_LOADER_H_
9 
10 #include <cstddef>
11 #include <memory>
12 #include <string>
13 
14 namespace treelite {
15 
16 class Model; // forward declaration
17 
18 namespace model_loader {
19 
20 //--------------------------------------------------------------------------
21 // Model loaders for XGBoost and LightGBM
22 //--------------------------------------------------------------------------
29 std::unique_ptr<treelite::Model> LoadXGBoostModelLegacyBinary(std::string const& filename);
36 std::unique_ptr<treelite::Model> LoadXGBoostModelLegacyBinary(void const* buf, std::size_t len);
44 std::unique_ptr<treelite::Model> LoadXGBoostModel(
45  std::string const& filename, char const* config_json);
54 std::unique_ptr<treelite::Model> LoadXGBoostModelFromString(
55  char const* json_str, std::size_t length, char const* config_json);
62 std::unique_ptr<treelite::Model> LoadLightGBMModel(std::string const& filename);
69 std::unique_ptr<treelite::Model> LoadLightGBMModelFromString(char const* model_str);
70 
71 //--------------------------------------------------------------------------
72 // Model loaders for Scikit-Learn models
73 //--------------------------------------------------------------------------
74 namespace sklearn {
102 std::unique_ptr<treelite::Model> LoadRandomForestRegressor(int n_estimators, int n_features,
103  int n_targets, std::int64_t const* node_count, std::int64_t const** children_left,
104  std::int64_t const** children_right, std::int64_t const** feature, double const** threshold,
105  double const** value, std::int64_t const** n_node_samples,
106  double const** weighted_n_node_samples, double const** impurity);
132 std::unique_ptr<treelite::Model> LoadIsolationForest(int n_estimators, int n_features,
133  std::int64_t const* node_count, std::int64_t const** children_left,
134  std::int64_t const** children_right, std::int64_t const** feature, double const** threshold,
135  double const** value, std::int64_t const** n_node_samples,
136  double const** weighted_n_node_samples, double const** impurity, double ratio_c);
165 std::unique_ptr<treelite::Model> LoadRandomForestClassifier(int n_estimators, int n_features,
166  int n_targets, int32_t const* n_classes, std::int64_t const* node_count,
167  std::int64_t const** children_left, std::int64_t const** children_right,
168  std::int64_t const** feature, double const** threshold, double const** value,
169  std::int64_t const** n_node_samples, double const** weighted_n_node_samples,
170  double const** impurity);
200 std::unique_ptr<treelite::Model> LoadGradientBoostingRegressor(int n_iter, int n_features,
201  std::int64_t const* node_count, std::int64_t const** children_left,
202  std::int64_t const** children_right, std::int64_t const** feature, double const** threshold,
203  double const** value, std::int64_t const** n_node_samples,
204  double const** weighted_n_node_samples, double const** impurity,
205  double const* baseline_prediction);
236 std::unique_ptr<treelite::Model> LoadGradientBoostingClassifier(int n_iter, int n_features,
237  int n_classes, std::int64_t const* node_count, std::int64_t const** children_left,
238  std::int64_t const** children_right, std::int64_t const** feature, double const** threshold,
239  double const** value, std::int64_t const** n_node_samples,
240  double const** weighted_n_node_samples, double const** impurity,
241  double const* baseline_prediction);
242 
271 std::unique_ptr<treelite::Model> LoadHistGradientBoostingRegressor(int n_iter, int n_features,
272  std::int64_t const* node_count, void const** nodes, int expected_sizeof_node_struct,
273  std::uint32_t n_categorical_splits, std::uint32_t const** raw_left_cat_bitsets,
274  std::uint32_t const* known_cat_bitsets, std::uint32_t const* known_cat_bitsets_offset_map,
275  std::int32_t const* features_map, std::int64_t const** categories_map,
276  double const* base_scores);
277 
309 std::unique_ptr<treelite::Model> LoadHistGradientBoostingClassifier(int n_iter, int n_features,
310  int n_classes, int64_t const* node_count, void const** nodes, int expected_sizeof_node_struct,
311  std::uint32_t n_categorical_splits, std::uint32_t const** raw_left_cat_bitsets,
312  std::uint32_t const* known_cat_bitsets, std::uint32_t const* known_cat_bitsets_offset_map,
313  std::int32_t const* features_map, std::int64_t const** categories_map,
314  double const* base_scores);
315 
316 } // namespace sklearn
317 
318 } // namespace model_loader
319 } // namespace treelite
320 
321 #endif // TREELITE_MODEL_LOADER_H_
std::unique_ptr< treelite::Model > LoadGradientBoostingRegressor(int n_iter, int n_features, std::int64_t const *node_count, std::int64_t const **children_left, std::int64_t const **children_right, std::int64_t const **feature, double const **threshold, double const **value, std::int64_t const **n_node_samples, double const **weighted_n_node_samples, double const **impurity, double const *baseline_prediction)
Load a scikit-learn GradientBoostingRegressor model from a collection of arrays. Refer to https://sci...
std::unique_ptr< treelite::Model > LoadIsolationForest(int n_estimators, int n_features, std::int64_t const *node_count, std::int64_t const **children_left, std::int64_t const **children_right, std::int64_t const **feature, double const **threshold, double const **value, std::int64_t const **n_node_samples, double const **weighted_n_node_samples, double const **impurity, double ratio_c)
Load a scikit-learn IsolationForest model from a collection of arrays. Refer to https://scikit-learn....
std::unique_ptr< treelite::Model > LoadRandomForestClassifier(int n_estimators, int n_features, int n_targets, int32_t const *n_classes, std::int64_t const *node_count, std::int64_t const **children_left, std::int64_t const **children_right, std::int64_t const **feature, double const **threshold, double const **value, std::int64_t const **n_node_samples, double const **weighted_n_node_samples, double const **impurity)
Load a scikit-learn RandomForestClassifier model from a collection of arrays. Refer to https://scikit...
std::unique_ptr< treelite::Model > LoadHistGradientBoostingClassifier(int n_iter, int n_features, int n_classes, int64_t const *node_count, void const **nodes, int expected_sizeof_node_struct, std::uint32_t n_categorical_splits, std::uint32_t const **raw_left_cat_bitsets, std::uint32_t const *known_cat_bitsets, std::uint32_t const *known_cat_bitsets_offset_map, std::int32_t const *features_map, std::int64_t const **categories_map, double const *base_scores)
Load a scikit-learn HistGradientBoostingClassifier model from a collection of arrays....
std::unique_ptr< treelite::Model > LoadRandomForestRegressor(int n_estimators, int n_features, int n_targets, std::int64_t const *node_count, std::int64_t const **children_left, std::int64_t const **children_right, std::int64_t const **feature, double const **threshold, double const **value, std::int64_t const **n_node_samples, double const **weighted_n_node_samples, double const **impurity)
Load a scikit-learn RandomForestRegressor model from a collection of arrays. Refer to https://scikit-...
std::unique_ptr< treelite::Model > LoadHistGradientBoostingRegressor(int n_iter, int n_features, std::int64_t const *node_count, void const **nodes, int expected_sizeof_node_struct, std::uint32_t n_categorical_splits, std::uint32_t const **raw_left_cat_bitsets, std::uint32_t const *known_cat_bitsets, std::uint32_t const *known_cat_bitsets_offset_map, std::int32_t const *features_map, std::int64_t const **categories_map, double const *base_scores)
Load a scikit-learn HistGradientBoostingRegressor model from a collection of arrays....
std::unique_ptr< treelite::Model > LoadGradientBoostingClassifier(int n_iter, int n_features, int n_classes, std::int64_t const *node_count, std::int64_t const **children_left, std::int64_t const **children_right, std::int64_t const **feature, double const **threshold, double const **value, std::int64_t const **n_node_samples, double const **weighted_n_node_samples, double const **impurity, double const *baseline_prediction)
Load a scikit-learn GradientBoostingClassifier model from a collection of arrays. Refer to https://sc...
std::unique_ptr< treelite::Model > LoadLightGBMModel(std::string const &filename)
load a model file generated by LightGBM (Microsoft/LightGBM). The model file must contain a decision ...
std::unique_ptr< treelite::Model > LoadXGBoostModelLegacyBinary(std::string const &filename)
Load a model file generated by XGBoost (dmlc/xgboost), stored in the legacy binary format.
std::unique_ptr< treelite::Model > LoadXGBoostModel(std::string const &filename, char const *config_json)
Load a model file generated by XGBoost (dmlc/xgboost), stored in the JSON format.
std::unique_ptr< treelite::Model > LoadXGBoostModelFromString(char const *json_str, std::size_t length, char const *config_json)
Load an XGBoost model from a JSON string.
std::unique_ptr< treelite::Model > LoadLightGBMModelFromString(char const *model_str)
Load a LightGBM model from a string. The string should be created with the model_to_string() method i...
Definition: contiguous_array.h:14