- Notifications
You must be signed in to change notification settings - Fork0
Lightweight Decision Trees Framework supporting Gradient Boosting (GBDT, GBRT, GBM), Random Forest and Adaboost w/categorical features support for Python
License
PythonExpert/chefboost
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Chefboost is a lightweightgradient boosting,random forest andadaboost enabled decision tree framework including regularID3,C4.5,CART,CHAID andregression tree algorithmswith categorical features support. It is lightweight, you just need to writea few lines of code to build decision trees with Chefboost.
Basically, you just need to pass the dataset as pandas data frame and tree configurations after importing Chefboost as illustrated below. You just need to put the target label to the right. Besides, chefboost handles both numeric and nominal features and target values in contrast to its alternatives.
fromchefboostimportChefboostaschefimportpandasaspddf=pd.read_csv("dataset/golf.txt")config= {'algorithm':'ID3'}model=chef.fit(df,config)
Built decision trees are stored as python if statements in thetests/outputs/rules directory. A sample of decision rules is demonstrated below.
deffindDecision(Outlook,Temperature,Humidity,Wind,Decision):ifOutlook=='Rain':ifWind=='Weak':return'Yes'elifWind=='Strong':return'No'elifOutlook=='Sunny':ifHumidity=='High':return'No'elifHumidity=='Normal':return'Yes'elifOutlook=='Overcast':return'Yes'
Decision rules will be stored inoutputs/rules/ folder when you build decision trees. You can run the built decision tree for new instances as illustrated below.
test_instance= ['Sunny','Hot','High','Weak']model=chef.fit(df,config)prediction=chef.predict(model,test_instance)
You can consume built decision trees directly as well. In this way, you can restore already built decision trees and skip learning steps, or applytransfer learning. Loaded trees offer you findDecision method to test for new instances.
moduleName="outputs/rules/rules"#this will load outputs/rules/rules.pytree=chef.restoreTree(moduleName)prediction=tree.findDecision(['Sunny','Hot','High','Weak'])
tests/global-unit-test.py will guide you how to build a different decision trees and make predictions.
You can save your trained models.
model=chef.fit(df.copy(),config)chef.save_model(model,"model.pkl")
In this way, you can use the same model later to just make predictions. This skips the training steps. Restoration requires to store .py and .pkl files underoutputs/rules.
model=chef.load_model("model.pkl")prediction=chef.predict(model, ['Sunny',85,85,'Weak'])
Chefboost supports several decision tree, bagging and boosting algorithms. You just need to pass the configuration to use different algorithms.
Regular Decision TreesID3 Video,C4.5 Video,CART Video,CHAID Video,Regression Tree Video
config= {'algorithm':'C4.5'}#ID3, C4.5, CART, CHAID or Regression
Gradient BoostingVideo
config= {'enableGBM':True,'epochs':7,'learning_rate':1}
Random ForestVideo
config= {'enableRandomForest':True,'num_of_trees':5}
AdaboostVideo
config= {'enableAdaboost':True,'num_of_weak_classifier':4}
This YouTubeplaylist guides you how to use Chefboost step by step for different algorithms. You can also find the detailed documentations about these core algorithmshere.
Besides, you can enroll this online course -Decision Trees for Machine Learning From Scratch and follow the curriculum if you wonder the theory of decision trees and how this framework is developed.
The easiest way to install Chefboost framework is to download it fromfrom PyPI.
pip install chefboostAlternatively, you can directly download the source code from this repository.GitHub repo might be newer than the PyPI version.
git clone https://github.com/serengil/chefboost.gitcd chefboostpip install -e .Installation guideline is also captured as avideo.
Initial tests are run for Python 3.6.4 on Windows 10 but this is an OS-independent framework. Even though pip handles to install dependent libraries, the framework basically needs some dependencies. You might need the installthese dependencies if you'll install the source code from github.
There are many ways to support a project - starring⭐️ the GitHub repos is just one.
You can also support this project through Patreon.
Chefboost is licensed under the MIT License - seeLICENSE for more details.
Logo is created byTang Ge. Licensed underCreative Commons: By Attribution 3.0 License.
About
Lightweight Decision Trees Framework supporting Gradient Boosting (GBDT, GBRT, GBM), Random Forest and Adaboost w/categorical features support for Python
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Languages
- Python100.0%
