Python package for model stacking
Repository contains Python package with implementation of stacking for sklean classification models based on this Kaggle kernel.
- setup.py - package setup file.
- stacking - folder, which contains package source code.
- init.py - init file, which contains shortcuts for SklearnHelper class and get_oof function.
- stacking_implementation.py - package source code.
- Download package.
- Navigate to folder, containing package (specifically setup.py file).
- Type
pip install .
Example of usage of package SklearnHelper class and get_oof function
#import package
import stacking
#import sklearn model
from sklearn.ensemble import RandomForestClassifier
#define parameters for sklearn model
rf_params = {
'n_jobs': -1,
'n_estimators': 100,
'max_depth': 6,
'min_samples_leaf': 2,
'max_features' : 'sqrt',
'verbose': 0
}
#wrap model with SklearnHelper class from package
rf = SklearnHelper(clf=RandomForestClassifier, seed=42, params=rf_params)
#perform out of fold training of the model
rf_oof_train, rf_oof_test = get_oof(rf, X_train, y_train, X_test)