Skip to content

Commit 08974ea

Browse files
PaulZhutovskyReinier Koops
andauthored
Fixes the use of eval_metric in case of EarlyStoppingShapRFECV with LightGBM (#261)
This fixes issue #259 in the exact way described in the issue. It indeed removes the warning and uses the defined `eval_metric` in case of LightGBM. I have no idea how to "formally" test that. @ReinierKoops please advice. --------- Co-authored-by: Reinier Koops <info@reinier.work>
1 parent c1a6889 commit 08974ea

6 files changed

Lines changed: 64 additions & 65 deletions

File tree

.github/workflows/cronjob_unit_tests.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
os: ubuntu-latest
2222
- build: windows
2323
os: windows-latest
24-
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
24+
python-version: [3.9, "3.10", "3.11", "3.12"]
2525
steps:
2626
- uses: actions/checkout@master
2727

@@ -31,6 +31,11 @@ jobs:
3131
cmakeVersion: latest
3232
ninjaVersion: latest
3333

34+
- name: Install LIBOMP on Macos runners
35+
if: runner.os == 'macOS'
36+
run: |
37+
brew install libomp
38+
3439
- name: Setup Python
3540
uses: actions/setup-python@master
3641
with:

.github/workflows/unit_tests.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
os: ubuntu-latest
2121
- build: windows
2222
os: windows-latest
23-
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
23+
python-version: [3.9, "3.10", "3.11", "3.12"]
2424
steps:
2525
- uses: actions/checkout@master
2626

@@ -30,6 +30,11 @@ jobs:
3030
cmakeVersion: latest
3131
ninjaVersion: latest
3232

33+
- name: Install LIBOMP on Macos runners
34+
if: runner.os == 'macOS'
35+
run: |
36+
brew install libomp
37+
3338
- name: Setup Python
3439
uses: actions/setup-python@master
3540
with:

.pre-commit-config.yaml

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,58 @@ repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
33
rev: v3.2.0
44
hooks:
5-
- id: check-case-conflict # Different OSes
6-
name: 'Check case conflict: Naming of files is compatible with all OSes'
7-
- id: check-docstring-first
8-
name: 'Check docstring first: Ensures Docstring present and first'
9-
- id: detect-private-key
10-
name: 'Detect private key: Prevent commit of env related keys'
11-
- id: trailing-whitespace
12-
name: 'Trailing whitespace: Remove empty spaces'
5+
- id: check-case-conflict # Different OSes
6+
name: "Check case conflict: Naming of files is compatible with all OSes"
7+
- id: check-docstring-first
8+
name: "Check docstring first: Ensures Docstring present and first"
9+
- id: detect-private-key
10+
name: "Detect private key: Prevent commit of env related keys"
11+
- id: trailing-whitespace
12+
name: "Trailing whitespace: Remove empty spaces"
1313
- repo: https://github.com/nbQA-dev/nbQA
14-
rev: 1.7.0
14+
rev: 1.8.5
1515
hooks:
16-
- id: nbqa-ruff
17-
name: 'ruff nb: Check for errors, styling issues and complexity'
18-
- id: nbqa-mypy
19-
name: 'mypy nb: Static type checking'
20-
- id: nbqa-isort
21-
name: 'isort nb: Sort file imports'
22-
- id: nbqa-pyupgrade
23-
name: 'pyupgrade nb: Updates code to Python 3.8+ code convention'
24-
args: [&py_version --py37-plus]
25-
- id: nbqa-black
26-
name: 'black nb: PEP8 compliant code formatter'
16+
- id: nbqa-ruff
17+
name: "ruff nb: Check for errors, styling issues and complexity"
18+
- id: nbqa-mypy
19+
name: "mypy nb: Static type checking"
20+
- id: nbqa-isort
21+
name: "isort nb: Sort file imports"
22+
- id: nbqa-pyupgrade
23+
name: "pyupgrade nb: Updates code to Python 3.9+ code convention"
24+
args: [&py_version --py38-plus]
25+
- id: nbqa-black
26+
name: "black nb: PEP8 compliant code formatter"
2727
- repo: local
2828
hooks:
29-
- id: mypy
30-
name: 'mypy: Static type checking'
31-
entry: mypy
32-
language: system
33-
types: [python]
29+
- id: mypy
30+
name: "mypy: Static type checking"
31+
entry: mypy
32+
language: system
33+
types: [python]
3434
- repo: local
3535
hooks:
36-
- id: ruff-check
37-
name: 'Ruff: Check for errors, styling issues and complexity, and fixes issues if possible (including import order)'
38-
entry: ruff check
39-
language: system
40-
args: [ --fix, --no-cache ]
41-
- id: ruff-format
42-
name: 'Ruff: format code in line with PEP8'
43-
entry: ruff format
44-
language: system
45-
args: [ --no-cache ]
36+
- id: ruff-check
37+
name: "Ruff: Check for errors, styling issues and complexity, and fixes issues if possible (including import order)"
38+
entry: ruff check
39+
language: system
40+
args: [--fix, --no-cache]
41+
- id: ruff-format
42+
name: "Ruff: format code in line with PEP8"
43+
entry: ruff format
44+
language: system
45+
args: [--no-cache]
4646
- repo: local
4747
hooks:
48-
- id: codespell
49-
name: 'codespell: Check for grammar'
50-
entry: codespell
51-
language: system
52-
types: [python]
53-
args: [-L mot] # Skip the word "mot"
48+
- id: codespell
49+
name: "codespell: Check for grammar"
50+
entry: codespell
51+
language: system
52+
types: [python]
53+
args: [-L mot] # Skip the word "mot"
5454
- repo: https://github.com/asottile/pyupgrade
5555
rev: v3.4.0
5656
hooks:
57-
- id: pyupgrade
58-
name: 'pyupgrade: Updates code to Python 3.8+ code convention'
59-
args: [*py_version]
57+
- id: pyupgrade
58+
name: "pyupgrade: Updates code to Python 3.9+ code convention"
59+
args: [*py_version]

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This will allow you to quickly see if the work you made contains some adaptions
4848

4949
## Standards
5050

51-
- Python 3.8+
51+
- Python 3.9+
5252
- Follow [PEP8](http://pep8.org/) as closely as possible (except line length)
5353
- [google docstring format](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/)
5454
- Git: Include a short description of *what* and *why* was done, *how* can be seen in the code. Use present tense, imperative mood

probatus/feature_elimination/early_stopping_feature_elimination.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def _get_fit_params_lightGBM(
239239
"X": X_train,
240240
"y": y_train,
241241
"eval_set": [(X_val, y_val)],
242+
"eval_metric": self.eval_metric,
242243
"callbacks": [
243244
early_stopping(self.early_stopping_rounds, first_metric_only=True),
244245
log_evaluation(1 if self.verbose >= 2 else 0),
@@ -507,14 +508,6 @@ def _get_feature_shap_values_per_fold(
507508

508509
# Due to deprecation issues (compatibility with Sklearn) set some params
509510
# like below, instead of through fit().
510-
try:
511-
from lightgbm import LGBMModel
512-
513-
if isinstance(model, LGBMModel):
514-
model.set_params(eval_metric=self.eval_metric)
515-
except ImportError:
516-
pass
517-
518511
try:
519512
from xgboost.sklearn import XGBModel
520513

pyproject.toml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "probatus"
7-
version = "3.1.0"
8-
requires-python= ">=3.8"
7+
version = "3.1.1"
8+
requires-python= ">=3.9"
99
description = "Validation of regression & classifiers and data used to develop them"
1010
readme = { file = "README.md", content-type = "text/markdown" }
1111
authors = [
@@ -16,7 +16,6 @@ classifiers = [
1616
"Intended Audience :: Developers",
1717
"Intended Audience :: Science/Research",
1818
"Programming Language :: Python :: 3",
19-
"Programming Language :: Python :: 3.8",
2019
"Programming Language :: Python :: 3.9",
2120
"Programming Language :: Python :: 3.10",
2221
"Programming Language :: Python :: 3.11",
@@ -33,9 +32,8 @@ dependencies = [
3332
"scipy>=1.4.0",
3433
"joblib>=0.13.2",
3534
"tqdm>=4.41.0",
36-
"shap==0.43.0 ; python_version == '3.8'",
37-
"shap>=0.43.0 ; python_version != '3.8'",
38-
"numpy>=1.23.2",
35+
"shap>=0.43.0",
36+
"numpy>=1.23.2,<2.0.0",
3937
"numba>=0.57.0",
4038
"loguru>=0.7.2",
4139
]
@@ -66,9 +64,7 @@ dev = [
6664
"codespell>=2.2.4",
6765
"ruff>=0.2.2",
6866
"lightgbm>=3.3.0",
69-
# https://github.com/catboost/catboost/issues/2371
70-
"catboost>=1.2 ; python_version != '3.8'",
71-
"catboost<1.2 ; python_version == '3.8'",
67+
"catboost>=1.2",
7268
"xgboost>=1.5.0",
7369
"scipy>=1.4.0",
7470
]
@@ -93,7 +89,7 @@ isort = ["--profile=black"]
9389
black = ["--line-length=120"]
9490

9591
[tool.mypy]
96-
python_version = "3.8"
92+
python_version = "3.9"
9793
ignore_missing_imports = true
9894
namespace_packages = true
9995
pretty = true

0 commit comments

Comments
 (0)