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
)
xgb_params = {
"learning_rate": 0.65,
"max_depth": 10,
}
monotonic_quantile_xgb.train(params=xgb_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.2.tar.gz
(5.5 kB
view details)
Built Distribution
File details
Details for the file quantile_tree-0.1.2.tar.gz
.
File metadata
- Download URL: quantile_tree-0.1.2.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0798785341aaa471d0708451276003dedb10e05c47de1d9365f8dead36ab16f |
|
MD5 | 54f7e45ef9a02720e2d8826fe5b16963 |
|
BLAKE2b-256 | f83ae01570f93a3b349677b8ad1b676ac5e1c7477764d6732da805f5daaff4ef |
File details
Details for the file quantile_tree-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: quantile_tree-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54de76ff246964fd71f85ceff4bedd27798c4929a89a3820dd83c1b110f182f0 |
|
MD5 | 7f8c04f1fc56149f41af5df669ea2693 |
|
BLAKE2b-256 | 0e37bc098f59b2d81c9fa7e3a1c60224e32689c76297b0e38d8bf4e8ac2581da |