https://github.com/pankajr141/ensembler
Powerful stacking/blending ensemble implementation in python.
https://github.com/pankajr141/ensembler
blending ensemble ensemble-learning stacking
Last synced: 11 months ago
JSON representation
Powerful stacking/blending ensemble implementation in python.
- Host: GitHub
- URL: https://github.com/pankajr141/ensembler
- Owner: pankajr141
- Created: 2016-01-27T05:51:06.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-07T06:57:29.000Z (about 10 years ago)
- Last Synced: 2024-04-25T18:01:15.832Z (about 2 years ago)
- Topics: blending, ensemble, ensemble-learning, stacking
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Usage
--------
Blending examples:
#### Example 1 - Using default meta estimator (LogisticRegression)
```shell
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.svm import SVC
from ensembler import blend
clfs = [
RandomForestClassifier(),
SVC(probability=True, degree=3, gamma=0.001, kernel='linear'),
ExtraTreesClassifier(max_depth=6, n_estimators=1000, max_features=None),
]
# Creating a blend/stack of 3 base level estimator with CV 3
blendModel = blend.BlendModel(clfs, nFoldsBase=3)
blendModel.fit(x, y)
predictions = blendModel.predict(xHoldout)
blendModel.score(xHoldout, yHoldOut)
```
#### Example 2 - Using custom meta estimator
```shell
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.svm import SVC
from ensembler import blend
clfs = [
RandomForestClassifier(),
SVC(probability=True, degree=3, gamma=0.001, kernel='linear'),
ExtraTreesClassifier(max_depth=6, n_estimators=1000, max_features=None),
]
# Tuning parameters for meta estimator
metaTunedParamsRF = {
'n_estimators': [2000, 1000, 500],
'max_depth': [4, 6]
}
metaEstimator = RandomForestClassifier()
metaTunedParams = metaTunedParamsRF
# saveAndPickBaseDump is useful when we dont want to train base level estimator again,
# it will initially train base estimatior and pickles them to disk.
# This is handy while trying various metaEstimators
# Creating a blend/stack of 3 base level estimator with CV 4 and custom metaEstimator
blendModel = blend.BlendModel(clfs, nFoldsBase=4,
saveAndPickBaseDump=True, saveAndPickBaseDumpLoc=r'pickle_dir',
metaEstimator=metaEstimator, metaTunedParams=metaTunedParams
)
blendModel.fit(x, y)
predictions = blendModel.predict(xHoldout)
blendModel.score(xHoldout, yHoldOut)
```
Installation
------------
#### Installing dependency
```pip install git+https://github.com/fmfn/BayesianOptimization.git```