Skip to content

Commit 8431c38

Browse files
committed
remove pin on scikit-learn and skip all the load_boston() tests
1 parent b95c865 commit 8431c38

5 files changed

Lines changed: 31 additions & 25 deletions

File tree

.ci/test.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ fi
120120

121121
# hack around https://github.com/microsoft/LightGBM/pull/5619#issuecomment-1341935203 just to produce
122122
# a releasable artifact on Ubuntu 14.04
123-
PACKAGE_CONSTRAINTS="dask-core distributed pandas numpy scipy"
123+
PACKAGE_CONSTRAINTS="dask-core distributed pandas numpy scikit-learn scipy"
124124
if [[ $OS_NAME == "linux" ]] && [[ $COMPILER == "gcc" ]] && [[ $ARCH != "aarch64" ]]; then
125125
if [[ $TASK == "bdist" ]] || [[ $TASK == "regular" ]] || [[ $TASK == "mpi" ]]; then
126-
PACKAGE_CONSTRAINTS="dask-core<=2022.7.1 distributed<=2022.7.1 libstdcxx-ng<12.0 numpy<=1.20.0 pandas<=1.4.1 scipy<=1.8.0"
126+
PACKAGE_CONSTRAINTS="dask-core<=2022.7.1 distributed<=2022.7.1 libstdcxx-ng<12.0 numpy<=1.20.0 pandas<=1.4.1 scikit-learn<=1.1.0 scipy<=1.8.0"
127127
fi
128128
fi
129129

@@ -136,8 +136,7 @@ conda install -q -y -n $CONDA_ENV \
136136
pytest \
137137
${PACKAGE_CONSTRAINTS} \
138138
"python=$PYTHON_VERSION[build=*cpython]" \
139-
python-graphviz \
140-
'scikit-learn<1.2.0' || exit -1
139+
python-graphviz || exit -1
141140

142141
if [[ $OS_NAME == "macos" ]] && [[ $COMPILER == "clang" ]]; then
143142
# fix "OMP: Error #15: Initializing libiomp5.dylib, but found libomp.dylib already initialized." (OpenMP library conflict due to conda's MKL)

.ci/test_windows.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ if ($env:TASK -eq "swig") {
5151
}
5252

5353
# re-including python=version[build=*cpython] to ensure that conda doesn't fall back to pypy
54-
conda install -q -y -n $env:CONDA_ENV cloudpickle joblib matplotlib numpy pandas psutil pytest "python=$env:PYTHON_VERSION[build=*cpython]" python-graphviz 'scikit-learn<=1.1' scipy ; Check-Output $?
54+
conda install -q -y -n $env:CONDA_ENV cloudpickle joblib matplotlib numpy pandas psutil pytest "python=$env:PYTHON_VERSION[build=*cpython]" python-graphviz scikit-learn scipy ; Check-Output $?
5555

5656
if ($env:TASK -eq "regular") {
5757
mkdir $env:BUILD_SOURCESDIRECTORY/build; cd $env:BUILD_SOURCESDIRECTORY/build

tests/python_package_test/test_engine.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import lightgbm as lgb
1919

20-
from .utils import load_boston, load_breast_cancer, load_digits, load_iris
20+
from .utils import load_breast_cancer, load_digits, load_iris
2121

2222
decreasing_generator = itertools.count(0, -1)
2323

@@ -99,6 +99,7 @@ def test_rf():
9999

100100

101101
def test_regression():
102+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
102103
X, y = load_boston(return_X_y=True)
103104
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
104105
params = {
@@ -643,6 +644,7 @@ def test_early_stopping():
643644

644645

645646
def test_continue_train():
647+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
646648
X, y = load_boston(return_X_y=True)
647649
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
648650
params = {
@@ -671,6 +673,7 @@ def test_continue_train():
671673

672674

673675
def test_continue_train_reused_dataset():
676+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
674677
X, y = load_boston(return_X_y=True)
675678
params = {
676679
'objective': 'regression',
@@ -685,6 +688,7 @@ def test_continue_train_reused_dataset():
685688

686689

687690
def test_continue_train_dart():
691+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
688692
X, y = load_boston(return_X_y=True)
689693
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
690694
params = {
@@ -733,6 +737,7 @@ def test_continue_train_multiclass():
733737

734738

735739
def test_cv():
740+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
736741
X_train, y_train = load_boston(return_X_y=True)
737742
params = {'verbose': -1}
738743
lgb_train = lgb.Dataset(X_train, y_train)
@@ -837,6 +842,7 @@ def test_cvbooster():
837842

838843

839844
def test_feature_name():
845+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
840846
X_train, y_train = load_boston(return_X_y=True)
841847
params = {'verbose': -1}
842848
lgb_train = lgb.Dataset(X_train, y_train)
@@ -866,6 +872,7 @@ def test_feature_name_with_non_ascii():
866872

867873

868874
def test_save_load_copy_pickle():
875+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
869876
def train_and_predict(init_model=None, return_model=False):
870877
X, y = load_boston(return_X_y=True)
871878
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
@@ -1496,6 +1503,7 @@ def test_refit():
14961503

14971504

14981505
def test_mape_rf():
1506+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
14991507
X, y = load_boston(return_X_y=True)
15001508
params = {
15011509
'boosting_type': 'rf',
@@ -1514,6 +1522,7 @@ def test_mape_rf():
15141522

15151523

15161524
def test_mape_dart():
1525+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
15171526
X, y = load_boston(return_X_y=True)
15181527
params = {
15191528
'boosting_type': 'dart',
@@ -2052,6 +2061,7 @@ def test_default_objective_and_metric():
20522061

20532062
@pytest.mark.skipif(psutil.virtual_memory().available / 1024 / 1024 / 1024 < 3, reason='not enough RAM')
20542063
def test_model_size():
2064+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
20552065
X, y = load_boston(return_X_y=True)
20562066
data = lgb.Dataset(X, y)
20572067
bst = lgb.train({'verbose': -1}, data, num_boost_round=2)
@@ -2079,6 +2089,7 @@ def test_model_size():
20792089

20802090

20812091
def test_get_split_value_histogram():
2092+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
20822093
X, y = load_boston(return_X_y=True)
20832094
lgb_train = lgb.Dataset(X, y, categorical_feature=[2])
20842095
gbm = lgb.train({'verbose': -1}, lgb_train, num_boost_round=20)
@@ -2159,6 +2170,7 @@ def test_get_split_value_histogram():
21592170

21602171

21612172
def test_early_stopping_for_only_first_metric():
2173+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
21622174

21632175
def metrics_combination_train_regression(valid_sets, metric_list, assumed_iteration,
21642176
first_metric_only, feval=None):
@@ -2465,6 +2477,7 @@ def test_dataset_params_with_reference():
24652477

24662478

24672479
def test_extra_trees():
2480+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
24682481
# check extra trees increases regularization
24692482
X, y = load_boston(return_X_y=True)
24702483
lgb_x = lgb.Dataset(X, label=y)
@@ -2484,6 +2497,7 @@ def test_extra_trees():
24842497

24852498

24862499
def test_path_smoothing():
2500+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
24872501
# check path smoothing increases regularization
24882502
X, y = load_boston(return_X_y=True)
24892503
lgb_x = lgb.Dataset(X, label=y)
@@ -2554,6 +2568,7 @@ def _imptcs_to_numpy(X, impcts_dict):
25542568

25552569

25562570
def test_interaction_constraints():
2571+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
25572572
X, y = load_boston(return_X_y=True)
25582573
num_features = X.shape[1]
25592574
train_data = lgb.Dataset(X, label=y)
@@ -2709,6 +2724,7 @@ def test_linear_single_leaf():
27092724

27102725

27112726
def test_predict_with_start_iteration():
2727+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
27122728
def inner_test(X, y, params, early_stopping_rounds):
27132729
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
27142730
train_data = lgb.Dataset(X_train, label=y_train)

tests/python_package_test/test_sklearn.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import lightgbm as lgb
2020

21-
from .utils import load_boston, load_breast_cancer, load_digits, load_iris, load_linnerud, make_ranking
21+
from .utils import load_breast_cancer, load_digits, load_iris, load_linnerud, make_ranking
2222

2323
sk_version = parse_version(sk_version)
2424
if sk_version < parse_version("0.23"):
@@ -91,6 +91,7 @@ def test_binary():
9191

9292

9393
def test_regression():
94+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
9495
X, y = load_boston(return_X_y=True)
9596
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
9697
gbm = lgb.LGBMRegressor(n_estimators=50, silent=True)
@@ -157,6 +158,7 @@ def test_eval_at_aliases():
157158

158159

159160
def test_regression_with_custom_objective():
161+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
160162
X, y = load_boston(return_X_y=True)
161163
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
162164
gbm = lgb.LGBMRegressor(n_estimators=50, silent=True, objective=objective_ls)
@@ -180,6 +182,7 @@ def test_binary_classification_with_custom_objective():
180182

181183

182184
def test_dart():
185+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
183186
X, y = load_boston(return_X_y=True)
184187
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
185188
gbm = lgb.LGBMRegressor(boosting_type='dart', n_estimators=50)
@@ -217,6 +220,7 @@ def test_stacking_classifier():
217220
# sklearn <0.23 does not have a stacking regressor and n_features_in_ property
218221
@pytest.mark.skipif(sk_version < parse_version('0.23'), reason='scikit-learn version is less than 0.23')
219222
def test_stacking_regressor():
223+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
220224
from sklearn.ensemble import StackingRegressor
221225

222226
X, y = load_boston(return_X_y=True)
@@ -384,14 +388,6 @@ def test_regressor_chain():
384388

385389

386390
def test_clone_and_property():
387-
X, y = load_boston(return_X_y=True)
388-
gbm = lgb.LGBMRegressor(n_estimators=10, silent=True)
389-
gbm.fit(X, y, verbose=False)
390-
391-
gbm_clone = clone(gbm)
392-
assert isinstance(gbm.booster_, lgb.Booster)
393-
assert isinstance(gbm.feature_importances_, np.ndarray)
394-
395391
X, y = load_digits(n_class=2, return_X_y=True)
396392
clf = lgb.LGBMClassifier(n_estimators=10, silent=True)
397393
clf.fit(X, y, verbose=False)
@@ -402,6 +398,7 @@ def test_clone_and_property():
402398

403399

404400
def test_joblib():
401+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
405402
X, y = load_boston(return_X_y=True)
406403
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
407404
gbm = lgb.LGBMRegressor(n_estimators=10, objective=custom_asymmetric_obj,
@@ -644,6 +641,7 @@ def test_predict():
644641

645642

646643
def test_evaluate_train_set():
644+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
647645
X, y = load_boston(return_X_y=True)
648646
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
649647
gbm = lgb.LGBMRegressor(n_estimators=10, silent=True)
@@ -658,6 +656,7 @@ def test_evaluate_train_set():
658656

659657

660658
def test_metrics():
659+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
661660
X, y = load_boston(return_X_y=True)
662661
params = {'n_estimators': 2, 'verbose': -1}
663662
params_fit = {'X': X, 'y': y, 'eval_set': (X, y), 'verbose': False}
@@ -989,7 +988,7 @@ def test_nan_handle():
989988

990989

991990
def test_first_metric_only():
992-
991+
pytest.skip("load_boston() was removed in scikit-learn 1.2.0")
993992
def fit_and_check(eval_set_names, metric_names, assumed_iteration, first_metric_only):
994993
params['first_metric_only'] = first_metric_only
995994
gbm = lgb.LGBMRegressor(**params).fit(**params_fit)
@@ -1204,7 +1203,7 @@ def test_parameters_default_constructible(estimator):
12041203
check_parameters_default_constructible(name, Estimator)
12051204

12061205

1207-
@pytest.mark.parametrize('task', ['classification', 'ranking', 'regression'])
1206+
@pytest.mark.parametrize('task', ['classification', 'ranking'])
12081207
def test_training_succeeds_when_data_is_dataframe_and_label_is_column_array(task):
12091208
pd = pytest.importorskip("pandas")
12101209
if task == 'ranking':
@@ -1214,9 +1213,6 @@ def test_training_succeeds_when_data_is_dataframe_and_label_is_column_array(task
12141213
elif task == 'classification':
12151214
X, y = load_iris(return_X_y=True)
12161215
model_factory = lgb.LGBMClassifier
1217-
elif task == 'regression':
1218-
X, y = load_boston(return_X_y=True)
1219-
model_factory = lgb.LGBMRegressor
12201216
X = pd.DataFrame(X)
12211217
y_col_array = y.reshape(-1, 1)
12221218
params = {

tests/python_package_test/utils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
from sklearn.utils import check_random_state
77

88

9-
@lru_cache(maxsize=None)
10-
def load_boston(**kwargs):
11-
return sklearn.datasets.load_boston(**kwargs)
12-
13-
149
@lru_cache(maxsize=None)
1510
def load_breast_cancer(**kwargs):
1611
return sklearn.datasets.load_breast_cancer(**kwargs)

0 commit comments

Comments
 (0)