From 9114b9a88c4b173e0537ce5e21de08400e688fb3 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Thu, 26 Mar 2020 17:30:02 +0100 Subject: [PATCH 1/3] Skip check_no_attributes_set_in_init in check_estimator --- docker/dockerfile-python | 2 +- docker/gpu/dockerfile.gpu | 4 ++-- docs/GPU-Tutorial.rst | 2 +- docs/Python-API.rst | 4 ---- docs/Python-Intro.rst | 4 ++-- examples/python-guide/README.md | 2 +- python-package/lightgbm/sklearn.py | 3 --- python-package/setup.py | 2 +- tests/python_package_test/test_sklearn.py | 5 +++++ 9 files changed, 13 insertions(+), 15 deletions(-) diff --git a/docker/dockerfile-python b/docker/dockerfile-python index 4029a097fac4..1b1f73e04579 100644 --- a/docker/dockerfile-python +++ b/docker/dockerfile-python @@ -18,7 +18,7 @@ RUN apt-get update && \ export PATH="$CONDA_DIR/bin:$PATH" && \ conda config --set always_yes yes --set changeps1 no && \ # lightgbm - conda install -q -y numpy scipy "scikit-learn<=0.21.3" pandas && \ + conda install -q -y numpy scipy "scikit-learn<=0.22.0" pandas && \ git clone --recursive --branch stable --depth 1 https://github.com/Microsoft/LightGBM && \ cd LightGBM/python-package && python setup.py install && \ # clean diff --git a/docker/gpu/dockerfile.gpu b/docker/gpu/dockerfile.gpu index 2060b39974bf..f4865f61f3ed 100644 --- a/docker/gpu/dockerfile.gpu +++ b/docker/gpu/dockerfile.gpu @@ -75,8 +75,8 @@ RUN echo "export PATH=$CONDA_DIR/bin:"'$PATH' > /etc/profile.d/conda.sh && \ rm ~/miniconda.sh RUN conda config --set always_yes yes --set changeps1 no && \ - conda create -y -q -n py2 python=2.7 mkl numpy scipy "scikit-learn<=0.21.3" jupyter notebook ipython pandas matplotlib && \ - conda create -y -q -n py3 python=3.6 mkl numpy scipy "scikit-learn<=0.21.3" jupyter notebook ipython pandas matplotlib + conda create -y -q -n py2 python=2.7 mkl numpy scipy "scikit-learn!=0.22.0" jupyter notebook ipython pandas matplotlib && \ + conda create -y -q -n py3 python=3.6 mkl numpy scipy "scikit-learn!=0.22.0" jupyter notebook ipython pandas matplotlib ################################################################################################################# # LightGBM diff --git a/docs/GPU-Tutorial.rst b/docs/GPU-Tutorial.rst index dca95c1e2031..1a88f01ccb01 100644 --- a/docs/GPU-Tutorial.rst +++ b/docs/GPU-Tutorial.rst @@ -78,7 +78,7 @@ If you want to use the Python interface of LightGBM, you can install it now (alo :: sudo apt-get -y install python-pip - sudo -H pip install setuptools numpy scipy "scikit-learn<=0.21.3" -U + sudo -H pip install setuptools numpy scipy "scikit-learn!=0.22.0" -U cd python-package/ sudo python setup.py install --precompile cd .. diff --git a/docs/Python-API.rst b/docs/Python-API.rst index e87a3523223b..de6b1ec6f2b9 100644 --- a/docs/Python-API.rst +++ b/docs/Python-API.rst @@ -24,10 +24,6 @@ Training API Scikit-learn API ---------------- -.. warning:: - - The last supported version of scikit-learn is ``0.21.3``. Our estimators are incompatible with newer versions. - .. autosummary:: :toctree: pythonapi/ diff --git a/docs/Python-Intro.rst b/docs/Python-Intro.rst index 8293733809c5..db3bbfc19c20 100644 --- a/docs/Python-Intro.rst +++ b/docs/Python-Intro.rst @@ -15,11 +15,11 @@ Install ------- Install Python-package dependencies, -``setuptools``, ``wheel``, ``numpy`` and ``scipy`` are required, ``scikit-learn<=0.21.3`` is required for sklearn interface and recommended: +``setuptools``, ``wheel``, ``numpy`` and ``scipy`` are required, ``scikit-learn!=0.22.0`` is required for sklearn interface and recommended: :: - pip install setuptools wheel numpy scipy "scikit-learn<=0.21.3" -U + pip install setuptools wheel numpy scipy "scikit-learn!=0.22.0" -U Refer to `Python-package`_ folder for the installation guide. diff --git a/examples/python-guide/README.md b/examples/python-guide/README.md index 8ff716344d33..dc630172de6d 100644 --- a/examples/python-guide/README.md +++ b/examples/python-guide/README.md @@ -8,7 +8,7 @@ You should install LightGBM [Python-package](https://github.com/microsoft/LightG You also need scikit-learn, pandas, matplotlib (only for plot example), and scipy (only for logistic regression example) to run the examples, but they are not required for the package itself. You can install them with pip: ``` -pip install "scikit-learn<=0.21.3" pandas matplotlib scipy -U +pip install "scikit-learn!=0.22.0" pandas matplotlib scipy -U ``` Now you can run examples in this folder, for example: diff --git a/python-package/lightgbm/sklearn.py b/python-package/lightgbm/sklearn.py index e6d5b33a651f..d8637b7f1b8d 100644 --- a/python-package/lightgbm/sklearn.py +++ b/python-package/lightgbm/sklearn.py @@ -298,9 +298,6 @@ def __init__(self, boosting_type='gbdt', num_leaves=31, max_depth=-1, """ if not SKLEARN_INSTALLED: raise LightGBMError('Scikit-learn is required for this module') - elif SKLEARN_VERSION > '0.21.3': - raise RuntimeError("The last supported version of scikit-learn is 0.21.3.\n" - "Found version: {0}.".format(SKLEARN_VERSION)) self.boosting_type = boosting_type self.objective = objective diff --git a/python-package/setup.py b/python-package/setup.py index f04eaa405028..d308403d09ff 100644 --- a/python-package/setup.py +++ b/python-package/setup.py @@ -276,7 +276,7 @@ def run(self): install_requires=[ 'numpy', 'scipy', - 'scikit-learn<=0.21.3' + 'scikit-learn!=0.22.0' ], maintainer='Guolin Ke', maintainer_email='guolin.ke@microsoft.com', diff --git a/tests/python_package_test/test_sklearn.py b/tests/python_package_test/test_sklearn.py index 747508f0d5ce..e43bb129d8e5 100644 --- a/tests/python_package_test/test_sklearn.py +++ b/tests/python_package_test/test_sklearn.py @@ -293,6 +293,11 @@ def test_sklearn_integration(self): check_name = check.func.__name__ if hasattr(check, 'func') else check.__name__ if check_name == 'check_estimators_nan_inf': continue # skip test because LightGBM deals with nan + elif (check_name == "check_no_attributes_set_in_init" + and sk_version < '0.23.0'): + # scikit-learn <0.23 incorrectly asserts that private attributes + # cannot be set in __init__. + continue try: check(name, estimator) except SkipTest as message: From 3c0c798d2edb770778a6139edf84582fe1c4f482 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Thu, 26 Mar 2020 17:37:14 +0100 Subject: [PATCH 2/3] Fix typo --- docker/dockerfile-python | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/dockerfile-python b/docker/dockerfile-python index 1b1f73e04579..8e633ca1270e 100644 --- a/docker/dockerfile-python +++ b/docker/dockerfile-python @@ -18,7 +18,7 @@ RUN apt-get update && \ export PATH="$CONDA_DIR/bin:$PATH" && \ conda config --set always_yes yes --set changeps1 no && \ # lightgbm - conda install -q -y numpy scipy "scikit-learn<=0.22.0" pandas && \ + conda install -q -y numpy scipy "scikit-learn!=0.22.0" pandas && \ git clone --recursive --branch stable --depth 1 https://github.com/Microsoft/LightGBM && \ cd LightGBM/python-package && python setup.py install && \ # clean From 3e9b1f72efe53da8659c8b545812faa534f0e406 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Thu, 26 Mar 2020 17:45:59 +0100 Subject: [PATCH 3/3] Another occurence in CI --- .ci/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/test.sh b/.ci/test.sh index 1bc9124fc0a6..84728b494085 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -73,7 +73,7 @@ if [[ $TASK == "r-package" ]]; then exit 0 fi -conda install -q -y -n $CONDA_ENV joblib matplotlib numpy pandas psutil pytest python-graphviz "scikit-learn<=0.21.3" scipy +conda install -q -y -n $CONDA_ENV joblib matplotlib numpy pandas psutil pytest python-graphviz "scikit-learn!=0.22.0" scipy if [[ $OS_NAME == "macos" ]] && [[ $COMPILER == "clang" ]]; then # fix "OMP: Error #15: Initializing libiomp5.dylib, but found libomp.dylib already initialized." (OpenMP library conflict due to conda's MKL)