Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Lightweight Decision Trees Framework supporting Gradient Boosting (GBDT, GBRT, GBM), Random Forest and Adaboost w/categorical features support for Python

License

NotificationsYou must be signed in to change notification settings

PythonExpert/chefboost

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Downloads

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.

Usage

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)

Outcomes

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'

Testing for custom instances

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.

Model save and restoration

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'])

Sample configurations

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}

Documentation

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.

Installation

The easiest way to install Chefboost framework is to download it fromfrom PyPI.

pip install chefboost

Alternatively, 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.

Support

There are many ways to support a project - starring⭐️ the GitHub repos is just one.

You can also support this project through Patreon.

Licence

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python100.0%

[8]ページ先頭

©2009-2025 Movatter.jp