Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dumps from multi-quantile models include only first quantile #9926

Closed
david-cortes opened this issue Dec 26, 2023 · 2 comments
Closed

Dumps from multi-quantile models include only first quantile #9926

david-cortes opened this issue Dec 26, 2023 · 2 comments

Comments

@david-cortes
Copy link
Contributor

ref #9924

Trying to get a model text dump from a multi-output model ("multi_strategy" : "multi_output_tree") will produce an error, but if one tries to get a dump from a multi-quantile model, it will output only the leafs of the first quantile:

import numpy as np, xgboost as xgb
rng = np.random.default_rng(seed=123)
X = rng.standard_normal(size=(100,3))
y = rng.standard_normal(size=100)
dm = xgb.DMatrix(data=X, label=y)
model = xgb.train(
    dtrain=dm,
    params={
        "tree_method" : "hist",
        "objective" : "reg:quantileerror",
        "quantile_alpha" : [0.1, 0.5, 0.9],
        "max_depth" : 2
    },
    num_boost_round=1
)
xgb.plot_tree(model)

image

These leaves match with the first quantile:

import json
base = float(
    json.loads(model.save_raw("json").decode())
    ["learner"]
    ['learner_model_param']
    ['base_score']
)
pred = model.predict(dm, output_margin=True)
np.unique(pred[:,0]) - base
array([-0.5326223 , -0.4631673 , -0.40180442,  0.01188996], dtype=float32)

But they do not match with the rest of the quantiles:

array([-0.18282221,  0.0202435 ,  0.04176801,  0.12941198], dtype=float32)
@trivialfis
Copy link
Member

It's still working in progress, the vector leaf. We can safely ignore it for now.

@trivialfis
Copy link
Member

Closing in favor of #9043

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants