Skip to content

Commit 9c4cfb5

Browse files
authored
Upgrade LightGBM and remove nullable handling (#4237)
* Remove nullable type incompatibility tests * Remove nullable type handling from lightgbm * Bump min lightgbm version to 4.0.0
1 parent 841ac6d commit 9c4cfb5

File tree

10 files changed

+12
-104
lines changed

10 files changed

+12
-104
lines changed

.github/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ outputs:
7575
- ipywidgets >=7.5, <8.0.5
7676
- xgboost >=1.7.0
7777
- catboost >=1.1.1
78-
- lightgbm >=2.3.1
78+
- lightgbm >=4.0.0
7979
- lime >=0.2.0.1
8080
- python >=3.8.*
8181
- imbalanced-learn >=0.9.1, <0.11.0

docs/source/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Release Notes
66
* Fixes
77
* Changes
88
* Unpinned sktime version :pr:`4214`
9+
* Bumped minimum lightgbm version to 4.0.0 for nullable type handling :pr:`4237`
910
* Documentation Changes
1011
* Testing Changes
1112

evalml/pipelines/components/estimators/classifiers/lightgbm_classifier.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ class LightGBMClassifier(Estimator):
8484
SEED_MAX = SEED_BOUNDS.max_bound
8585
"""SEED_BOUNDS.max_bound"""
8686

87-
# Incompatibility: https://github.com/alteryx/evalml/issues/3924
88-
# TODO: Remove when support is added https://github.com/alteryx/evalml/issues/4017
89-
_integer_nullable_incompatibilities = ["X", "y"]
90-
_boolean_nullable_incompatibilities = ["X"]
91-
9287
def __init__(
9388
self,
9489
boosting_type="gbdt",
@@ -191,9 +186,8 @@ def fit(self, X, y=None):
191186
X = infer_feature_types(X)
192187
if y is not None:
193188
y = infer_feature_types(y)
194-
X_d, y_d = self._handle_nullable_types(X, y)
195-
X_encoded = self._encode_categories(X_d, fit=True)
196-
y_encoded = self._encode_labels(y_d)
189+
X_encoded = self._encode_categories(X, fit=True)
190+
y_encoded = self._encode_labels(y)
197191
self._component_obj.fit(X_encoded, y_encoded)
198192
return self
199193

@@ -207,8 +201,7 @@ def predict(self, X):
207201
pd.DataFrame: Predicted values.
208202
"""
209203
X_encoded = self._encode_categories(X)
210-
X_d, _ = self._handle_nullable_types(X_encoded)
211-
predictions = super().predict(X_d)
204+
predictions = super().predict(X_encoded)
212205
if not self._label_encoder:
213206
return predictions
214207
predictions = self._label_encoder.inverse_transform(
@@ -226,5 +219,4 @@ def predict_proba(self, X):
226219
pd.DataFrame: Predicted probability values.
227220
"""
228221
X_encoded = self._encode_categories(X)
229-
X_d, _ = self._handle_nullable_types(X_encoded)
230-
return super().predict_proba(X_d)
222+
return super().predict_proba(X_encoded)

evalml/pipelines/components/estimators/regressors/lightgbm_regressor.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ class LightGBMRegressor(Estimator):
7474
SEED_MAX = SEED_BOUNDS.max_bound
7575
"""SEED_BOUNDS.max_bound"""
7676

77-
# Incompatibility: https://github.com/alteryx/evalml/issues/3924
78-
# TODO: Remove when support is added https://github.com/alteryx/evalml/issues/4017
79-
_integer_nullable_incompatibilities = ["X", "y"]
80-
_boolean_nullable_incompatibilities = ["X", "y"]
81-
8277
def __init__(
8378
self,
8479
boosting_type="gbdt",
@@ -169,8 +164,7 @@ def fit(self, X, y=None):
169164
X_encoded = self._encode_categories(X, fit=True)
170165
if y is not None:
171166
y = infer_feature_types(y)
172-
X_d, y_d = self._handle_nullable_types(X_encoded, y)
173-
self._component_obj.fit(X_d, y_d)
167+
self._component_obj.fit(X_encoded, y)
174168
return self
175169

176170
def predict(self, X):
@@ -183,5 +177,4 @@ def predict(self, X):
183177
pd.Series: Predicted values.
184178
"""
185179
X_encoded = self._encode_categories(X)
186-
X_d, _ = self._handle_nullable_types(X_encoded)
187-
return super().predict(X_d)
180+
return super().predict(X_encoded)

evalml/tests/component_tests/test_lgbm_classifier.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -352,42 +352,3 @@ def test_lgbm_with_nullable_types(
352352

353353
assert not preds.isnull().any().any()
354354
assert not pred_probs.isnull().any().any()
355-
356-
357-
@pytest.mark.parametrize(
358-
"nullable_y_ltype",
359-
["IntegerNullable", "AgeNullable"],
360-
)
361-
@pytest.mark.parametrize(
362-
"handle_incompatibility",
363-
[
364-
True,
365-
pytest.param(
366-
False,
367-
marks=pytest.mark.xfail(strict=True, raises=ValueError),
368-
),
369-
],
370-
)
371-
def test_lgbm_classifier_nullable_type_incompatibility(
372-
nullable_type_target,
373-
nullable_type_test_data,
374-
lgbm,
375-
handle_incompatibility,
376-
nullable_y_ltype,
377-
):
378-
"""Testing that the nullable type incompatibility that caused us to add handling for LightGBMClassifier
379-
is still present in sklearn's LGBMClassifier component. If this test is causing the test suite to fail
380-
because the code below no longer raises the expected ValueError, we should confirm that the nullable
381-
types now work for our use case and remove the nullable type handling logic from LightGBMClassifier.
382-
"""
383-
y = nullable_type_target(ltype=nullable_y_ltype, has_nans=False)
384-
X = nullable_type_test_data(has_nans=False)
385-
X = X.ww.select(include=["numeric", "Boolean", "BooleanNullable"])
386-
387-
if handle_incompatibility:
388-
lgb = LightGBMClassifier()
389-
X, y = lgb._handle_nullable_types(X, y)
390-
391-
sk_lgb = lgbm.sklearn.LGBMClassifier()
392-
sk_lgb.fit(X, y)
393-
sk_lgb.predict(X)

evalml/tests/component_tests/test_lgbm_regressor.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -250,42 +250,3 @@ def test_lgbm_with_nullable_types(
250250
preds = lgb.predict(X.ww.copy())
251251

252252
assert not preds.isnull().any().any()
253-
254-
255-
@pytest.mark.parametrize(
256-
"nullable_y_ltype",
257-
["IntegerNullable", "AgeNullable", "BooleanNullable"],
258-
)
259-
@pytest.mark.parametrize(
260-
"handle_incompatibility",
261-
[
262-
True,
263-
pytest.param(
264-
False,
265-
marks=pytest.mark.xfail(strict=True, raises=ValueError),
266-
),
267-
],
268-
)
269-
def test_lgbm_regressor_nullable_type_incompatibility(
270-
nullable_type_target,
271-
nullable_type_test_data,
272-
lgbm,
273-
handle_incompatibility,
274-
nullable_y_ltype,
275-
):
276-
"""Testing that the nullable type incompatibility that caused us to add handling for LightGBMRegressor
277-
is still present in sklearn's LGBMRegressor component. If this test is causing the test suite to fail
278-
because the code below no longer raises the expected ValueError, we should confirm that the nullable
279-
types now work for our use case and remove the nullable type handling logic from LightGBMRegressor.
280-
"""
281-
y = nullable_type_target(ltype=nullable_y_ltype, has_nans=False)
282-
X = nullable_type_test_data(has_nans=False)
283-
X = X.ww.select(include=["numeric", "Boolean", "BooleanNullable"])
284-
285-
if handle_incompatibility:
286-
lgb = LightGBMRegressor()
287-
X, y = lgb._handle_nullable_types(X, y)
288-
289-
sk_lgb = lgbm.sklearn.LGBMRegressor()
290-
sk_lgb.fit(X, y)
291-
sk_lgb.predict(X)

evalml/tests/dependency_update_check/latest_dependency_versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ holidays==0.20
1212
imbalanced-learn==0.10.1
1313
ipywidgets==8.0.4
1414
kaleido==0.2.1
15-
lightgbm==3.3.5
15+
lightgbm==4.0.0
1616
lime==0.2.0.1
1717
matplotlib==3.7.2
1818
matplotlib-inline==0.1.6

evalml/tests/dependency_update_check/minimum_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ holidays==0.13
1212
imbalanced-learn==0.9.1
1313
ipywidgets==7.5
1414
kaleido==0.1.0
15-
lightgbm==2.3.1
15+
lightgbm==4.0.0
1616
lime==0.2.0.1
1717
matplotlib==3.3.3
1818
networkx==2.6

evalml/tests/dependency_update_check/minimum_test_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ holidays==0.13
1515
imbalanced-learn==0.9.1
1616
ipywidgets==7.5
1717
kaleido==0.1.0
18-
lightgbm==2.3.1
18+
lightgbm==4.0.0
1919
lime==0.2.0.1
2020
matplotlib==3.3.3
2121
nbval==0.9.3

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ dependencies = [
5252
"ipywidgets >= 7.5, < 8.0.5",
5353
"xgboost >= 1.7.0",
5454
"catboost >= 1.1.1",
55-
"lightgbm >= 2.3.1",
55+
"lightgbm >= 4.0.0",
5656
"matplotlib >= 3.3.3",
5757
"graphviz >= 0.13; platform_system!='Windows'",
5858
"seaborn >= 0.11.1",

0 commit comments

Comments
 (0)