Skip to main content

Implements Wide Boosting functions for popular boosting packages

Project description

wideboost

Implements wide boosting using popular boosting frameworks as a backend. XGBoost supports the most wideboost features currently. Previous versions supported LightGBM, but this has since been deprecated.

Getting started

pip install wideboost

Sample scripts

The examples folder contains sample scripts for regression, binary classification, multivariate classification and multioutput binary classification. Currently xgboost is the only supported backend.

Starter script

import xgboost as xgb
from wideboost.wrappers import wxgb
from pydataset import data
import numpy as np

########
## Get and format the data
DAT = np.asarray(data('Yogurt'))
X = DAT[:,0:9]
Y = np.zeros([X.shape[0],1])
Y[DAT[:,9] == 'dannon'] = 1
Y[DAT[:,9] == 'hiland'] = 2
Y[DAT[:,9] == 'weight'] = 3
Y = wxgb.onehot(Y)

n = X.shape[0]
np.random.seed(123)
train_idx = np.random.choice(np.arange(n),round(n*0.4),replace=False)
test_idx = np.setdiff1d(np.arange(n),train_idx)

xtrain, ytrain = X[train_idx,:], Y[train_idx,]
xtest, ytest = X[test_idx,:],Y[test_idx,]
########

param = {
    'eta':0.1,
    'btype':'I',      ## wideboost param -- one of 'I', 'In', 'R', 'Rn'
    'extra_dims':1,   ## wideboost param -- integer >= -output_dim
    'beta_eta': 0.01, ## wideboost param -- learning rate for B. Can be unstable -- set to 0 to start.
    'output_dim': 4,  ## wideboost param -- Y must be in a 2D format (ie not a vector of categories)
    'objective':'manybinary:logistic',  ## treat response columns as separate binary problems
    'eval_metric':['many_logloss']      ## average binary logloss across columns
}

num_round = 100
watchlist = [((xtrain, ytrain),'train'),((xtest, ytest),'test')]
wxgb_results = dict()
bst = wxgb.fit(xtrain, ytrain, param, num_round, watchlist, evals_result=wxgb_results, verbose_eval=10)

Parameter Explanations

  • 'btype' indicates how to initialize the beta matrix. Settings are 'I', 'In', 'R', 'Rn'.
  • 'beta_eta' learning rate for the beta matrix. Sometimes unstable. Start with 0.
  • 'output_dim' width of Y. All Y need to be in 2D matrix format and onehotted if doing categorical prediction.
  • 'extra_dims' integer indicating how many "wide" dimensions are used. When 'extra_dims' is set to 0 (and 'btype' is set to 'I' and 'beta_eta' is 0) then wide boosting is equivalent to standard gradient boosting.

New Objectives

  • 'multi:squarederror' multidimension output regression.
  • 'manybinary:logistic' loss is independent logloss average across response columns

New Evals

  • 'many_logloss' logloss averaged across response columns
  • 'many_auc' auc averaged across response columns

Reference

https://arxiv.org/pdf/2007.09855.pdf

Analyses included in the paper are in the examples/paper_examples/ folder.

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

wideboost-0.4.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

wideboost-0.4.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file wideboost-0.4.0.tar.gz.

File metadata

  • Download URL: wideboost-0.4.0.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for wideboost-0.4.0.tar.gz
Algorithm Hash digest
SHA256 9241a207ea95535324cea4e911043f438a5f24cce6cec202e7805e4ac8fa5fb5
MD5 76b66e9d12c4f91f58ac80b85e54442f
BLAKE2b-256 0c47d6d820f273263faddc520f501ccaa74bd4ff18a78017d71e13725f6199c9

See more details on using hashes here.

File details

Details for the file wideboost-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: wideboost-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for wideboost-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5afa5d1ad2c73387607c4046336c3932dcd8dbc06c3db1133bb88cee9cfa8df8
MD5 3380bbfa81e107ffc1462cbe60975c78
BLAKE2b-256 1386a152321f56aa737e904d798af5e4efdb4200ef0a0f70df09cdd5e60c5056

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