Taijin Kim
Taijin Kim

Reputation: 95

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

Upvotes: 9

Views: 10782

Answers (4)

M. Reza Andalibi
M. Reza Andalibi

Reputation: 155

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

Upvotes: 0

Prateek Sharma
Prateek Sharma

Reputation: 1561

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 (with underscore)

from sklearn.utils._testing import ignore_warnings

Upvotes: 8

Am_official
Am_official

Reputation: 525

For 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)

Upvotes: 1

Ph03nIX
Ph03nIX

Reputation: 423

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)

Upvotes: -2

Related Questions