diff --git a/tests/python_package_test/test_sklearn.py b/tests/python_package_test/test_sklearn.py index 0fb7424f3b58..a7a0ef40dacd 100644 --- a/tests/python_package_test/test_sklearn.py +++ b/tests/python_package_test/test_sklearn.py @@ -558,8 +558,10 @@ def test_inf_handle(self): y = np.random.randn(nrows) + np.full(nrows, 1e30) weight = np.full(nrows, 1e10) params = {'n_estimators': 20, 'verbose': -1} - params_fit = {'X': X, 'y': y, 'sample_weight': weight, 'eval_set': (X, y), 'verbose': False, 'early_stopping_rounds': 5} + params_fit = {'X': X, 'y': y, 'sample_weight': weight, 'eval_set': (X, y), + 'verbose': False, 'early_stopping_rounds': 5} gbm = lgb.LGBMRegressor(**params).fit(**params_fit) + np.testing.assert_array_equal(gbm.evals_result_['training']['l2'], np.inf) def test_nan_handle(self): nrows = 1000 @@ -568,5 +570,7 @@ def test_nan_handle(self): y = np.random.randn(nrows) + np.full(nrows, 1e30) weight = np.zeros(nrows) params = {'n_estimators': 20, 'verbose': -1} - params_fit = {'X': X, 'y': y, 'sample_weight': weight, 'eval_set': (X, y), 'verbose': False, 'early_stopping_rounds': 5} + params_fit = {'X': X, 'y': y, 'sample_weight': weight, 'eval_set': (X, y), + 'verbose': False, 'early_stopping_rounds': 5} gbm = lgb.LGBMRegressor(**params).fit(**params_fit) + np.testing.assert_array_equal(gbm.evals_result_['training']['l2'], np.nan)