Skip to content

ModuleNotFoundError: No module named 'sklearn.utils.testing' #285

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

Closed
ghost opened this issue Jan 18, 2021 · 5 comments
Closed

ModuleNotFoundError: No module named 'sklearn.utils.testing' #285

ghost opened this issue Jan 18, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Jan 18, 2021

Describe the bug
from causalml import metrics causes ModuleNotFoundError: No module named 'sklearn.utils.testing'

To Reproduce
Steps to reproduce the behavior:

----> 1 from causalml import metrics

~/opt/anaconda3/envs/ollivander/lib/python3.7/site-packages/causalml/metrics/__init__.py in <module>
      1 from .classification import roc_auc_score, logloss, classification_metrics  # noqa
      2 from .regression import ape, mape, mae, rmse, r2_score, gini, smape, regression_metrics # noqa
----> 3 from .visualize import plot, plot_gain, plot_lift, plot_qini, plot_tmlegain, plot_tmleqini # noqa
      4 from .visualize import get_cumgain, get_cumlift, get_qini, get_tmlegain, get_tmleqini # noqa
      5 from .visualize import auuc_score, qini_score # noqa

~/opt/anaconda3/envs/ollivander/lib/python3.7/site-packages/causalml/metrics/visualize.py in <module>
      5 import seaborn as sns
      6 from lightgbm import LGBMRegressor
----> 7 from ..inference.meta.tmle import TMLELearner
      8 
      9 

~/opt/anaconda3/envs/ollivander/lib/python3.7/site-packages/causalml/inference/meta/__init__.py in <module>
      1 from .slearner import LRSRegressor, BaseSLearner, BaseSRegressor, BaseSClassifier
----> 2 from .tlearner import XGBTRegressor, MLPTRegressor, BaseTLearner, BaseTRegressor, BaseTClassifier
      3 from .xlearner import BaseXLearner, BaseXRegressor, BaseXClassifier
      4 from .rlearner import BaseRLearner, BaseRRegressor, BaseRClassifier, XGBRRegressor
      5 from .tmle import TMLELearner

~/opt/anaconda3/envs/ollivander/lib/python3.7/site-packages/causalml/inference/meta/tlearner.py in <module>
      6 from sklearn.exceptions import ConvergenceWarning
      7 from sklearn.neural_network import MLPRegressor
----> 8 from sklearn.utils.testing import ignore_warnings
      9 from xgboost import XGBRegressor
     10 
ModuleNotFoundError: No module named 'sklearn.utils.testing'

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: macOS
  • Python Version: Python 3.7.9
  • Versions of Major Dependencies (pandas, scikit-learn, cython): [e.g. pandas==1.2.0, scikit-learn==0.24.0]

Additional context
I guess there is some collision between conda and pip

@ghost ghost added the bug Something isn't working label Jan 18, 2021
@ghost
Copy link
Author

ghost commented Jan 18, 2021

The sklearn.utils.testing module is deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.utils. Anything that cannot be imported from sklearn.utils is now part of the private API.

@jeongyoonlee
Copy link
Collaborator

Thanks for filling the issue. It was addressed in #283, and will be available in the next PyPI release.

Meanwhile, you can either use scikit-learn==0.23 with causalml==0.9 or install causalml from the repo.

Best,

@ghost
Copy link
Author

ghost commented Jan 18, 2021

thanks. p.s. have you seen this ? "cannot import name 'getargspec_no_self' from 'scipy._lib._util'"

@daheelee
Copy link
Collaborator

Could you please open a separate issue for the second question?

mariaderrico added a commit to mariaderrico/DPA that referenced this issue Mar 18, 2021
sklearn.utils.testing module is deprecated in version 0.22 and will be removed in version 0.24: uber/causalml#285
@am-official
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants