• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

popcorn/xgb2cpp: Converts XGBoost raw model dumps to C++ code.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

popcorn/xgb2cpp

开源软件地址:

https://github.com/popcorn/xgb2cpp

开源编程语言:

Python 100.0%

开源软件介绍:

xgb2cpp

xgb2cpp converts XGBoost raw text dump to C++ code that you can use in your C++ projects.

READ FIRST

This code (atm) only works on XGB models trained with 'multi:softprob' objective. 'multi:softprob' objective tells XGBoost to train trees in "1 vs. all" fashion. If you want it to work with 'binary:logistic' or 'binary:logitraw' you'll have to tweak code-generating Python script a bit or wait for me to implement it.

How to run it?

Use generate_cpp_code.py script to generate xgboost_classifier.cpp. Generated xgboost_classifier.cpp will contain xgb_classify() function that you can use to classify samples. In folder sample you can find main.cpp and xgboost_classifier.h files that form use case project.

Also, there is a pima-indian-diabetes dataset that I used to generate dummy model. File /sample/pima-indians-diabetes/train.py trains XGB model and creates dump.raw.txt which is raw text representation of trained model.

Example run:

cd sample/pima-indians-diabetes
# Train model and generate dump.raw.txt
python train.py
cd ../../
# Generate xgboost_classifier.cpp
python python generate_cpp_code.py --num_classes=2 --xgb_dump=sample/pima-indians-diabetes/dump.raw.txt
# Copy xgboost_classifier.cpp to sample project
cp xgboost_classifier.cpp sample/codeblocks_project/xgboost_classifier.cpp
# Now build and run main.cpp, xgboost_classifier.cpp and xgboost_classifier.h in sample/codeblocks_project

If you have any questions or improvements just open issue and I'll be on it. Thanks




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap