Skip to content

Commit

Permalink
Merge pull request #6570 from PrimozGodec/fix-xgboost
Browse files Browse the repository at this point in the history
Gradient boosting - Adapt tests to version xgboost=2; move xgboost/catboost to regular requirements
  • Loading branch information
markotoplak committed Sep 15, 2023
2 parents 480930e + 68b5d5f commit 3dd6d9c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 22 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies on MacOS
run: brew install libomp
if: runner.os == 'macOS'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
24 changes: 12 additions & 12 deletions Orange/widgets/model/tests/test_owgradientboosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
from Orange.widgets.widget import OWWidget


def get_tree_train_params(model):
ln = json.loads(model.skl_model.get_booster().save_config())["learner"]
try:
return ln["gradient_booster"]["tree_train_param"]
except KeyError:
return ln["gradient_booster"]["updater"]["grow_colmaker"]["train_param"]


def create_parent(editor_class):
class DummyWidget(OWWidget):
name = "Mock"
Expand Down Expand Up @@ -158,9 +166,7 @@ def test_default_parameters_cls(self):
booster = XGBClassifier()
model = booster(data)
params = model.skl_model.get_params()
booster_params = json.loads(model.skl_model.get_booster().save_config())
updater = booster_params["learner"]["gradient_booster"]["updater"]
tp = updater["grow_colmaker"]["train_param"]
tp = get_tree_train_params(model)
self.assertEqual(params["n_estimators"], self.editor.n_estimators)
self.assertEqual(
round(float(tp["learning_rate"]), 1), self.editor.learning_rate
Expand All @@ -178,9 +184,7 @@ def test_default_parameters_reg(self):
booster = XGBRegressor()
model = booster(data)
params = model.skl_model.get_params()
booster_params = json.loads(model.skl_model.get_booster().save_config())
updater = booster_params["learner"]["gradient_booster"]["updater"]
tp = updater["grow_colmaker"]["train_param"]
tp = get_tree_train_params(model)
self.assertEqual(params["n_estimators"], self.editor.n_estimators)
self.assertEqual(
round(float(tp["learning_rate"]), 1), self.editor.learning_rate
Expand Down Expand Up @@ -223,9 +227,7 @@ def test_default_parameters_cls(self):
booster = XGBRFClassifier()
model = booster(data)
params = model.skl_model.get_params()
booster_params = json.loads(model.skl_model.get_booster().save_config())
updater = booster_params["learner"]["gradient_booster"]["updater"]
tp = updater["grow_colmaker"]["train_param"]
tp = get_tree_train_params(model)
self.assertEqual(params["n_estimators"], self.editor.n_estimators)
self.assertEqual(
round(float(tp["learning_rate"]), 1), self.editor.learning_rate
Expand All @@ -243,9 +245,7 @@ def test_default_parameters_reg(self):
booster = XGBRFRegressor()
model = booster(data)
params = model.skl_model.get_params()
booster_params = json.loads(model.skl_model.get_booster().save_config())
updater = booster_params["learner"]["gradient_booster"]["updater"]
tp = updater["grow_colmaker"]["train_param"]
tp = get_tree_train_params(model)
self.assertEqual(params["n_estimators"], self.editor.n_estimators)
self.assertEqual(
round(float(tp["learning_rate"]), 1), self.editor.learning_rate
Expand Down
2 changes: 2 additions & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ requirements:
- cachecontrol >=0.12.6
- qtconsole >=4.7.2
- pygments >=2.8.0
- catboost >=1.0.1
- xgboost >=1.7.4

test:
# Python imports
Expand Down
2 changes: 2 additions & 0 deletions requirements-core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ pandas>=1.4.0,!=1.5.0,!=2.0.0
pyyaml
openpyxl
httpx>=0.21.0
catboost>=1.0.1
xgboost>=1.7.4
2 changes: 0 additions & 2 deletions requirements-opt.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements-readthedocs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ cython
-r requirements-doc.txt
-r requirements-gui.txt
-r requirements-pyqt.txt
# for orange data mining library catboost and xgboost required
-r requirements-opt.txt
-e .
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ deps =
pyqt5==5.15.*;platform_system!="Windows" or python_version>='3.10'
pyqtwebengine==5.12.*;platform_system=="Windows" and python_version<'3.10'
pyqtwebengine==5.15.*;platform_system!="Windows" or python_version>='3.10'
-r {toxinidir}/requirements-opt.txt
coverage
psycopg2-binary
pymssql<3.0
Expand Down Expand Up @@ -66,7 +65,7 @@ deps =
# oldest: pyyaml
# oldest: openpyxl
oldest: httpx==0.21.0
oldest: xgboost==1.5.0
oldest: xgboost==1.7.4
oldest: catboost==1.0.1

commands_pre =
Expand Down

0 comments on commit 3dd6d9c

Please sign in to comment.