Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python] specify the last supported version of scikit-learn #2637

Merged
merged 1 commit into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ install:
- activate
- conda config --set always_yes yes --set changeps1 no
- conda update -q -y conda
- conda create -q -y -n test-env python=%PYTHON_VERSION% joblib matplotlib numpy pandas psutil pytest python-graphviz scikit-learn scipy
- conda create -q -y -n test-env python=%PYTHON_VERSION% joblib matplotlib numpy pandas psutil pytest python-graphviz "scikit-learn<=0.21.3" scipy
- activate test-env

build_script:
Expand Down
2 changes: 1 addition & 1 deletion .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,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 scipy
conda install -q -y -n $CONDA_ENV joblib matplotlib numpy pandas psutil pytest python-graphviz "scikit-learn<=0.21.3" 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)
Expand Down
2 changes: 1 addition & 1 deletion .vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
displayName: Enable conda
- script: |
cmd /c "activate & conda config --set always_yes yes --set changeps1 no & conda update -q -y conda & conda create -q -y -n %CONDA_ENV% python=%PYTHON_VERSION% joblib matplotlib numpy pandas psutil pytest python-graphviz scikit-learn scipy"
cmd /c 'activate & conda config --set always_yes yes --set changeps1 no & conda update -q -y conda & conda create -q -y -n %CONDA_ENV% python=%PYTHON_VERSION% joblib matplotlib numpy pandas psutil pytest python-graphviz "scikit-learn<=0.21.3" scipy'
cmd /c "activate %CONDA_ENV% & powershell -ExecutionPolicy Bypass -File %BUILD_SOURCESDIRECTORY%/.ci/test_windows.ps1"
displayName: Test
- task: PublishBuildArtifacts@1
Expand Down
2 changes: 1 addition & 1 deletion docker/dockerfile-python
Original file line number Diff line number Diff line change
Expand Up @@ -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 pandas && \
conda install -q -y numpy scipy "scikit-learn<=0.21.3" pandas && \
git clone --recursive --branch stable --depth 1 https://github.com/Microsoft/LightGBM && \
cd LightGBM/python-package && python setup.py install && \
# clean
Expand Down
4 changes: 2 additions & 2 deletions docker/gpu/dockerfile.gpu
Original file line number Diff line number Diff line change
Expand Up @@ -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 jupyter notebook ipython pandas matplotlib && \
conda create -y -q -n py3 python=3.6 mkl numpy scipy scikit-learn jupyter notebook ipython pandas matplotlib
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

#################################################################################################################
# LightGBM
Expand Down
4 changes: 2 additions & 2 deletions docs/GPU-Tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LightGBM GPU Tutorial
LightGBM GPU Tutorial
=====================

The purpose of this document is to give you a quick step-by-step tutorial on GPU training.
Expand Down Expand Up @@ -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 -U
sudo -H pip install setuptools numpy scipy "scikit-learn<=0.21.3" -U
cd python-package/
sudo python setup.py install --precompile
cd ..
Expand Down
4 changes: 4 additions & 0 deletions docs/Python-API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ 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/

Expand Down
4 changes: 2 additions & 2 deletions docs/Python-Intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Install
-------

Install Python-package dependencies,
``setuptools``, ``wheel``, ``numpy`` and ``scipy`` are required, ``scikit-learn`` is required for sklearn interface and recommended:
``setuptools``, ``wheel``, ``numpy`` and ``scipy`` are required, ``scikit-learn<=0.21.3`` is required for sklearn interface and recommended:

::

pip install setuptools wheel numpy scipy scikit-learn -U
pip install setuptools wheel numpy scipy "scikit-learn<=0.21.3" -U

Refer to `Python-package`_ folder for the installation guide.

Expand Down
2 changes: 1 addition & 1 deletion examples/python-guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 pandas matplotlib scipy -U
pip install "scikit-learn<=0.21.3" pandas matplotlib scipy -U
```

Now you can run examples in this folder, for example:
Expand Down
2 changes: 2 additions & 0 deletions python-package/lightgbm/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class DataTable(object):
from sklearn.cross_validation import StratifiedKFold, GroupKFold
from sklearn.utils.validation import NotFittedError
SKLEARN_INSTALLED = True
from sklearn import __version__ as SKLEARN_VERSION
_LGBMModelBase = BaseEstimator
_LGBMRegressorBase = RegressorMixin
_LGBMClassifierBase = ClassifierMixin
Expand All @@ -140,6 +141,7 @@ class DataTable(object):
_LGBMComputeSampleWeight = compute_sample_weight
except ImportError:
SKLEARN_INSTALLED = False
SKLEARN_VERSION = '0.0.0'
_LGBMModelBase = object
_LGBMClassifierBase = object
_LGBMRegressorBase = object
Expand Down
5 changes: 4 additions & 1 deletion python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np

from .basic import Dataset, LightGBMError, _ConfigAliases
from .compat import (SKLEARN_INSTALLED, _LGBMClassifierBase,
from .compat import (SKLEARN_INSTALLED, SKLEARN_VERSION, _LGBMClassifierBase,
LGBMNotFittedError, _LGBMLabelEncoder, _LGBMModelBase,
_LGBMRegressorBase, _LGBMCheckXY, _LGBMCheckArray, _LGBMCheckConsistentLength,
_LGBMAssertAllFinite, _LGBMCheckClassificationTargets, _LGBMComputeSampleWeight,
Expand Down Expand Up @@ -294,6 +294,9 @@ 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
Expand Down
2 changes: 1 addition & 1 deletion python-package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def run(self):
install_requires=[
'numpy',
'scipy',
'scikit-learn'
'scikit-learn<=0.21.3'
],
maintainer='Guolin Ke',
maintainer_email='[email protected]',
Expand Down