Skip to main content

Monotonic composite quantile gradient boost regressor

Project description

MQBoost

Multiple quantiles estimation model maintaining non-crossing condition (or monotone quantile condition) using:

  • LightGBM
  • XGBoost

Installation

Install using pip:

pip install mqboost

Usage

Features

  • MQRegressor: quantile regressor

Parameters

x         # Explanatory data (e.g. pd.DataFrame)
          # Column name '_tau' must be not included
y         # Response data (e.g. np.ndarray)
alphas    # Target quantiles
objective # [Optional] objective to minimize, "check"(default) or "huber"
model     # [Optional] boost algorithm to use, "lightgbm"(default) or "xgboost"
delta     # [Optional] parameter in "huber" objective, used when objective == "huber"
          # It must be smaller than 0.1

Methods

train     # train quantile model
          # Any params related to model can be used except "objective"
predict   # predict with input data

Example

import numpy as np
from mqboost import MQRegressor

## Generate sample
sample_size = 500
x = np.linspace(-10, 10, sample_size)
y = np.sin(x) + np.random.uniform(-0.4, 0.4, sample_size)
x_test = np.linspace(-10, 10, sample_size)
y_test = np.sin(x_test) + np.random.uniform(-0.4, 0.4, sample_size)

## target quantiles
alphas = [0.3, 0.4, 0.5, 0.6, 0.7]

## LightGBM based quantile regressor
mq_lgb = MQRegressor(
    x=x,
    y=y_test,
    alphas=alphas,
)
lgb_params = {
    "max_depth": 4,
    "num_leaves": 15,
    "learning_rate": 0.1,
    "boosting_type": "gbdt",
}
mq_lgb.train(params=lgb_params)
preds_lgb = mq_lgb.predict(x=x_test, alphas=alphas)

## XGBoost based quantile regressor
mq_xgb = MQRegressor(
    x=x,
    y=y_test,
    alphas=alphas,
    objective="check",
    model="xgboost",
)
xgb_params = {
    "learning_rate": 0.65,
    "max_depth": 10,
}
mq_xgb.train(params=xgb_params)
preds_xgb = mq_xgb.predict(x=x_test, alphas=alphas)

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

mqboost-0.0.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

mqboost-0.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file mqboost-0.0.0.tar.gz.

File metadata

  • Download URL: mqboost-0.0.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for mqboost-0.0.0.tar.gz
Algorithm Hash digest
SHA256 7a31e4a748bb467558e4644960cb9ee26571cc5d3ad19c4e32c85b2dfbe356b1
MD5 5c656f4c99fd209103d2bf41558d922c
BLAKE2b-256 8b62d0f3773f3f23bd89930cf440c0f526bef0bc1a876112bc094787fcde5cb4

See more details on using hashes here.

File details

Details for the file mqboost-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: mqboost-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for mqboost-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a7fe042990acbd3d2d9cb401975dbafd19a03c2a68c0e7710de479c78ceb2a7
MD5 cf04969d90212f1bf649bb276dc2470d
BLAKE2b-256 dc6db5be091baae6e78f6e1743e2f1daabc42ba22e465a96985ca04dc0932d7f

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