Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

[WIP] Fix ImportError for scikit-learn >= 0.23 - #904

Closed
jwmueller wants to merge 5 commits into
scikit-optimize:masterfrom
jwmueller:patch-1
Closed

jwmueller wants to merge 5 commits into
scikit-optimize:masterfrom
jwmueller:patch-1

Conversation

@jwmueller

Copy link
Copy Markdown

Fixes issue: #902

Without this fix, all packages that depend on scikit-optimize are now broken unless they manually downgrade their sklearn version.
Note that the sklearn MaskedArray was anyway only needed for outdated versions of numpy:
https://github.com/scikit-learn/scikit-learn/blob/0.22.X/sklearn/utils/fixes.py#L159

Fixes issue:  scikit-optimize#902

Without this fix, all packages that depend on scikit-optimize are now broken unless they manually downgrade their sklearn version.
Note that the sklearn MaskedArray was anyway only needed for outdated versions of numpy: 
https://github.com/scikit-learn/scikit-learn/blob/0.22.X/sklearn/utils/fixes.py#L159
@pep8speaks

pep8speaks commented May 13, 2020 •

Copy link
Copy Markdown

Hello @jwmueller! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-05-18 18:36:56 UTC

@jwmueller jwmueller changed the title Fix ImportError for scikit-learn >= 0.23 [MRG] Fix ImportError for scikit-learn >= 0.23 May 13, 2020
@jwmueller

Copy link
Copy Markdown
Author

All CI tests pass except for one using scikit-learn 0.21.3, but it's unclear why that one failed. That version of scikit-learn contains the same MaskedArray code as all the other versions in the passed CI tests: https://github.com/scikit-learn/scikit-learn/blob/0.21.3/sklearn/utils/fixes.py#L166

@betatim

betatim commented May 13, 2020 •

Copy link
Copy Markdown
Member

The tests that fail are related to comparing two arrays that should be the same/very similar but are wildly different now. My guess is that the calculations that lead to them make use of masked arrays somewhere :-/

why it works with the latest scikit-learn, sklearn 0.20 but not 0.21 is a bit of a mystery. Needs some diving into the code I suspect or analysing which versions of numpy are installed in each CI run.

@jwmueller jwmueller changed the title [MRG] Fix ImportError for scikit-learn >= 0.23 [WIP] Fix ImportError for scikit-learn >= 0.23 May 13, 2020
run CI without change to verify
@jwmueller

Copy link
Copy Markdown
Author

@betatim I think there's an issue in the CI tests. The same test fails when I just committed a "dummy test" version of the code with no change from master...

This is the failing test:

DISTRIB="conda" PYTHON_VERSION="3.7" NUMPY_VERSION="1.16.0" SCIPY_VERSION="1.0.0" PYAML_VERSION="17.8.0" SCIKIT_LEARN_VERSION="0.21.3" MATPLOTLIB_VERSION="*" COVERAGE="true" JOBLIB_VERSION="0.13"

@rth

rth commented May 13, 2020

Copy link
Copy Markdown

So the breakage is the result of scikit-learn/scikit-learn#16725 which removed backports for numpy <1.12.0. The test that failed in the second commit did so for numpy 1.16.0, in which case,

from sklearn.utils.fixes import MaskedArray

should be exactly equivalent to,

from numpy.ma import MaskedArray

so the initial fix should indeed work.

@betatim

betatim commented May 18, 2020

Copy link
Copy Markdown
Member

@jwmueller can you push the commit with your proposed change (and maybe squash the "not used anymore" ones)?

CI with no changes fails because of the problem you are trying to fix here (I think) :)

@holgern

holgern commented May 18, 2020 •

Copy link
Copy Markdown
Contributor

Should we use the same dependecies as scikit-learn?

scikit-learn requires:

Python (>= 3.6)
NumPy (>= 1.13.3)
SciPy (>= 0.19.1)
joblib (>= 0.11)

@betatim

betatim commented May 18, 2020 •

Copy link
Copy Markdown
Member

I think increasing the minimum required version of scikit-learn to 0.21 (last two releases before the current one) would be good and reduce the amount of cross dependency compatibility issues. This will also raise the minimum required version of numpy, scipy and joblib. Or put differently: I wouldn't raise those other dependencies to above what scikit-learn requires.

Dropping Python 3.5 also seems fine as it is pretty old.

@holgern

holgern commented May 18, 2020

Copy link
Copy Markdown
Contributor

@jwmueller Can you push the changes for MaskedArray again?

I will take care of the failing CI.

@holgern

holgern commented May 18, 2020

Copy link
Copy Markdown
Contributor

The CI is fixed in pr #906
image

Waiting for your fix on MaskedArray :)

@holgern

holgern commented May 18, 2020 •

Copy link
Copy Markdown
Contributor

betatim and others added 2 commits May 18, 2020 13:23
@jwmueller

Copy link
Copy Markdown
Author

@holgern @betatim I've re-added the changes and now the CI test for sklearn==0.21.3 passes where it failed before. But your newly added CI test for sklearn==0.23.0 now fails.

Please feel free to take over and modify the code yourself. It's probably not worth you waiting for my responses just to address these 3-line code changes...

@holgern

holgern commented May 20, 2020

Copy link
Copy Markdown
Contributor

The unit tests are broken due to changes in sklearn 0.23 on Gaussian processes regression: scikit-learn/scikit-learn#15782

@holgern

holgern commented Sep 3, 2020

Copy link
Copy Markdown
Contributor

Has been fixed in #939

@holgern holgern closed this Sep 3, 2020
sqbl added a commit to bytesandbrains/ProcessOptimizer that referenced this pull request Sep 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants