Skip to main content

Library for high level model ensembling

Project description

PyPI version PyPI license PyPI pyversions

fast-ensemble

Scikit-learn-style library for effecient and convenient high level table model ensembling


Usage Example:

Initialize Stack

from catboost import CatBoostRegressor
from lightgbm import LGBMRegressor
from sklearn.datasets import make_regression
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.metrics import mean_squared_error
from xgboost import XGBRegressor

from fast_ensemble import StackingTransformer
from fast_ensemble import (
    CatBoostRegressorWrapper,
    LGBMRegressorWrapper,
    XGBRegressorWrapper,
)

stack_1 = StackingTransformer(
    models=[
        (
            "catboost",
            CatBoostRegressorWrapper(
                CatBoostRegressor(verbose=0),
                use_best_model=True,
                early_stopping_rounds=100,
            ),
        ),
        (
            "xgboost",
            XGBRegressorWrapper(
                XGBRegressor(), use_best_model=True, early_stopping_rounds=100
            ),
        ),
        (
            "lgmb",
            LGBMRegressorWrapper(
                LGBMRegressor(), use_best_model=True, early_stopping_rounds=100
            ),
        ),
        ("boosting", GradientBoostingRegressor()),
    ],
    main_metric=mean_squared_error,
    regression=True,
    n_folds=5,
    random_state=None,
    shuffle=False,
    verbose=True,
    stratified=True,
    stratification_bins=7
)

And another one

stack_2 = StackingTransformer(
    models=[
        ("Dummy Regressor", DummyRegressor()),
    ],
    main_metric=mean_squared_error,
    regression=True,
    n_folds=5,
    random_state=None,
    shuffle=False,
    verbose=True,
    stratified=True,
    stratification_bins=7
)

Train your stacks (and get transformed dataframes)

X, y = make_regression(n_targets=1)

X_1_trans = stack_1.fit_transform(X, y)
X_2_trans = stack_2.fit_transform(X, y)

Want to merge 2 stacks for convenience? Here you go!

stack_1.merge(stack_2)

stack_1.get_scores(prettified=True)

       catboost       xgboost          lgmb      boosting  Dummy Regressor
0   9852.055535  23389.781003   8872.055479  13130.504063    21344.359900
1  14259.407424  20177.587908  12040.548492  14088.529604    28620.260635
2  16393.254421  24267.409682   9503.011118  15067.349045    33377.287468
3  12694.791124  16349.931831   7188.301326  10675.853608    29510.019041
4  17505.264716  12158.834533  10273.547605   9621.041119    39099.670810

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast-ensemble-0.0.5.tar.gz (7.1 kB view details)

Uploaded Source

File details

Details for the file fast-ensemble-0.0.5.tar.gz.

File metadata

  • Download URL: fast-ensemble-0.0.5.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for fast-ensemble-0.0.5.tar.gz
Algorithm Hash digest
SHA256 40ed0a58ebab2e7d39c1c880893ee83ccbc4a7d831055a82da86dbee7744b6a4
MD5 d849ec295c306d62ae3bfac113effd12
BLAKE2b-256 fd01b2dcf72159b5acce5c0f826d75cfa74e8f5d154f9cb06a3dfbd206a72ec8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page