Monotone quantile regressor
Project description
quantile-tree
Non-crossing quantile estimation with:
- LightGBM
- XGBoost
Installation
Install using pip:
pip install quantile-tree
Usage
Features
- QuantileRegressorLgb: quantile regressor based on LightGBM
- QuantileRegressorXgb: quantile regressor based on XGBoost
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"
delta # [Optional] parameter in "huber" objective, used when objective == "huber"
# delta 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 quantile_tree import QuantileRegressorLgb, QuantileRegressorXgb
## 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]
## QuantileRegressorLgb
monotonic_quantile_lgb = QuantileRegressorLgb(
x=x,
y=y_test,
alphas=alphas,
objective="huber",
delta=0.05,
)
lgb_params = {
"max_depth": 4,
"num_leaves": 15,
"learning_rate": 0.1,
"boosting_type": "gbdt",
}
monotonic_quantile_lgb.train(params=lgb_params)
preds_lgb = monotonic_quantile_lgb.predict(x=x_test, alphas=alphas)
## QuantileRegressorXgb
monotonic_quantile_xgb = QuantileRegressorXgb(
x=x,
y=y_test,
alphas=alphas
)
params = {
"learning_rate": 0.65,
"max_depth": 10,
}
monotonic_quantile_xgb.train(params=params)
preds_xgb = monotonic_quantile_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
quantile_tree-0.1.1.tar.gz
(9.6 kB
view hashes)
Built Distribution
Close
Hashes for quantile_tree-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3c9cbe5d2724614eb10f4d3f4dd0b9eea9d542b133120fd8a75868f0c966c46 |
|
MD5 | 658307f3924138956138d41b8996fbfa |
|
BLAKE2b-256 | 38209a0a498c859c2a7b8eda813212776773d9e4de51d8e59e0850fa802b9e2d |