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

[Meta Schedule][XGBoost] enable custom callback func test with xgboost>=1.6.0 #17168

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 6 additions & 19 deletions tests/python/meta_schedule/test_meta_schedule_cost_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,6 @@ def test_meta_schedule_xgb_model_reupdate():
model.predict(TuneContext(), [_dummy_candidate() for i in range(predict_sample_count)])


def xgb_version_check():

# pylint: disable=import-outside-toplevel
import xgboost as xgb
from packaging import version

# pylint: enable=import-outside-toplevel
return version.parse(xgb.__version__) >= version.parse("1.6.0")


@unittest.skipIf(xgb_version_check(), "test not supported for xgboost version after 1.6.0")
def test_meta_schedule_xgb_model_callback_as_function():
# pylint: disable=import-outside-toplevel
from itertools import chain as itertools_chain
Expand Down Expand Up @@ -330,14 +319,12 @@ def avg_peak_score(ys_pred: np.ndarray, d_train1: "xgb.DMatrix"): # type: ignor
num_boost_round=10000,
obj=obj,
callbacks=[
partial(
_get_custom_call_back(
early_stopping_rounds=model.early_stopping_rounds,
verbose_eval=model.verbose_eval,
fevals=[rmse, avg_peak_score],
evals=[(d_train.dmatrix, "tr")],
cvfolds=None,
)
_get_custom_call_back(
early_stopping_rounds=model.early_stopping_rounds,
verbose_eval=model.verbose_eval,
fevals=[rmse, avg_peak_score],
evals=[(d_train.dmatrix, "tr")],
cvfolds=None,
)
],
)
Expand Down
Loading