dask / dask-ml

Scalable Machine Learning with Dask
http://ml.dask.org
BSD 3-Clause "New" or "Revised" License
903 stars 256 forks source link

ImportError: cannot import name '_is_constant_feature' from 'sklearn.preprocessing._data #893

Open patilaum opened 2 years ago

patilaum commented 2 years ago

What happened: I installed dask ml by pip3 install git+https://github.com/dask/dask-ml.git But when tried importing dask ml got this error -

ImportError                               Traceback (most recent call last)
<ipython-input-116-dd5446b79649> in <module>
      3 import shapely.wkb
      4 # from sklearn.preprocessing import MinMaxScaler
----> 5 from dask_ml.preprocessing import MinMaxScaler
      6 
      7 from shapely.wkt import loads

~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/dask_ml/__init__.py in <module>
      2 
      3 # Ensure we always register tokenizers
----> 4 from dask_ml.model_selection import _normalize
      5 
      6 __all__ = []

~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/dask_ml/model_selection/__init__.py in <module>
      4 on the underlying estimators being used.
      5 """
----> 6 from ._hyperband import HyperbandSearchCV
      7 from ._incremental import IncrementalSearchCV, InverseDecaySearchCV
      8 from ._search import GridSearchCV, RandomizedSearchCV, check_cv, compute_n_splits

~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/dask_ml/model_selection/_hyperband.py in <module>
     10 from sklearn.utils import check_random_state
     11 
---> 12 from ._incremental import BaseIncrementalSearchCV
     13 from ._successive_halving import SuccessiveHalvingSearchCV
     14 

~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/dask_ml/model_selection/_incremental.py in <module>
     20 from distributed.utils import log_errors
     21 from sklearn.base import BaseEstimator, clone
---> 22 from sklearn.linear_model import SGDClassifier
     23 from sklearn.metrics import check_scoring
     24 from sklearn.model_selection import ParameterGrid, ParameterSampler

~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/sklearn/linear_model/__init__.py in <module>
      7 # complete documentation.
      8 
----> 9 from ._base import LinearRegression
     10 from ._bayes import BayesianRidge, ARDRegression
     11 from ._least_angle import (

~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/sklearn/linear_model/_base.py in <module>
     28 
     29 from ..base import BaseEstimator, ClassifierMixin, RegressorMixin, MultiOutputMixin
---> 30 from ..preprocessing._data import _is_constant_feature
     31 from ..utils import check_array
     32 from ..utils.validation import FLOAT_DTYPES

ImportError: cannot import name '_is_constant_feature' from 'sklearn.preprocessing._data' (/home/aum/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/sklearn/preprocessing/_data.py)

Anything else we need to know?: My scikit-learn version is 1.0.1. I tried downgrading to 0.21 but still getting same issue.

TomAugspurger commented 2 years ago

Sounds like a bad scikit-learn install. Can you try creating a new environment?

On Tue, Dec 7, 2021 at 9:02 AM patilaum @.***> wrote:

What happened: I installed dask ml by pip3 install git+ https://github.com/dask/dask-ml.git But when tried importing dask ml got this error -

ImportError Traceback (most recent call last)

in 3 import shapely.wkb 4 # from sklearn.preprocessing import MinMaxScaler ----> 5 from dask_ml.preprocessing import MinMaxScaler 6 7 from shapely.wkt import loads ~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/dask_ml/__init__.py in 2 3 # Ensure we always register tokenizers ----> 4 from dask_ml.model_selection import _normalize 5 6 __all__ = [] ~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/dask_ml/model_selection/__init__.py in 4 on the underlying estimators being used. 5 """ ----> 6 from ._hyperband import HyperbandSearchCV 7 from ._incremental import IncrementalSearchCV, InverseDecaySearchCV 8 from ._search import GridSearchCV, RandomizedSearchCV, check_cv, compute_n_splits ~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/dask_ml/model_selection/_hyperband.py in 10 from sklearn.utils import check_random_state 11 ---> 12 from ._incremental import BaseIncrementalSearchCV 13 from ._successive_halving import SuccessiveHalvingSearchCV 14 ~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/dask_ml/model_selection/_incremental.py in 20 from distributed.utils import log_errors 21 from sklearn.base import BaseEstimator, clone ---> 22 from sklearn.linear_model import SGDClassifier 23 from sklearn.metrics import check_scoring 24 from sklearn.model_selection import ParameterGrid, ParameterSampler ~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/sklearn/linear_model/__init__.py in 7 # complete documentation. 8 ----> 9 from ._base import LinearRegression 10 from ._bayes import BayesianRidge, ARDRegression 11 from ._least_angle import ( ~/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/sklearn/linear_model/_base.py in 28 29 from ..base import BaseEstimator, ClassifierMixin, RegressorMixin, MultiOutputMixin ---> 30 from ..preprocessing._data import _is_constant_feature 31 from ..utils import check_array 32 from ..utils.validation import FLOAT_DTYPES ImportError: cannot import name '_is_constant_feature' from 'sklearn.preprocessing._data' (/home/aum/projects/fractal/glassdoor-review-scraper/fract/lib/python3.8/site-packages/sklearn/preprocessing/_data.py) *Anything else we need to know?*: My scikit-learn version is 1.0.1. I tried downgrading to 0.21 but still getting same issue. - Dask version: 2.30.0 - Python version: 3.8.10 - Operating System: Ubuntu 20.04 - Install method (conda, pip, source): pip — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub , or unsubscribe .