简体   繁体   中英

ModuleNotFoundError: No Module named 'sklearn.utils._testing'

from sklearn.utils._testing import ignore_warnings

ModuleNotFoundError: No Module named 'sklearn.utils._testing'

How Could I solve this problem? My sklearn version is 0.21.3

Those who are facing ModuleNotFoundError: No module named 'sklearn.utils.testing'

import sklearn
estimators = sklearn.utils.all_estimators(type_filter=None)
for name, class_ in estimators:
    if hasattr(class_, 'predict_proba'):
        print(name)

In version 0.21.3: sklearn.utils. testing

from sklearn.utils.testing import ignore_warnings

In version 0.24.1 or later Link :
sklearn.utils. _testing

from sklearn.utils._testing import ignore_warnings

For those facing the following error ModuleNotFoundError: No module named 'sklearn.utils.testing', an alternative solution to that of @desertnaut would be to load from the root rather than from testing:

from sklearn.utils import all_estimators

As mentioned by @ywbaek, the following import fixes this problem for Scikit-learn version: 0.21.3 :

from sklearn.utils.testing import ignore_warnings

sklearn.utils._testing may be introduced in a later version (as observed from SK Github Repo )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM