scikit-learn: ImportError: cannot import name 'CategoricalEncoder'

As simple as that. See below for system info. Tried uninstalling and re-installing package. CategoricalEncoder is nowhere to be found in the pip-distributed package

Steps/Code to Reproduce

Example:

>>> python
>>> from sklearn.preprocessing import CategoricalEncoder
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'CategoricalEncoder'

Versions

>>> import platform; print(platform.platform())
Darwin-17.2.0-x86_64-i386-64bit
>>> import sys; print("Python", sys.version)
Python 3.6.1 (default, Apr  4 2017, 09:40:21) 
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)]
>>> import numpy; print("NumPy", numpy.__version__)
NumPy 1.14.0
>>> import scipy; print("SciPy", scipy.__version__)
SciPy 1.0.0
>>> import sklearn; print("Scikit-Learn", sklearn.__version__)
Scikit-Learn 0.19.1

The __init__.py in sklearn.preprocessing looks like this, which shows CategoricalEncoder is not included/implemented

"""
The :mod:`sklearn.preprocessing` module includes scaling, centering,
normalization, binarization and imputation methods.
"""

from ._function_transformer import FunctionTransformer

from .data import Binarizer
from .data import KernelCenterer
from .data import MinMaxScaler
from .data import MaxAbsScaler
from .data import Normalizer
from .data import RobustScaler
from .data import StandardScaler
from .data import QuantileTransformer
from .data import add_dummy_feature
from .data import binarize
from .data import normalize
from .data import scale
from .data import robust_scale
from .data import maxabs_scale
from .data import minmax_scale
from .data import quantile_transform
from .data import OneHotEncoder

from .data import PolynomialFeatures

from .label import label_binarize
from .label import LabelBinarizer
from .label import LabelEncoder
from .label import MultiLabelBinarizer

from .imputation import Imputer


__all__ = [
    'Binarizer',
    'FunctionTransformer',
    'Imputer',
    'KernelCenterer',
    'LabelBinarizer',
    'LabelEncoder',
    'MultiLabelBinarizer',
    'MinMaxScaler',
    'MaxAbsScaler',
    'QuantileTransformer',
    'Normalizer',
    'OneHotEncoder',
    'RobustScaler',
    'StandardScaler',
    'add_dummy_feature',
    'PolynomialFeatures',
    'binarize',
    'normalize',
    'scale',
    'robust_scale',
    'maxabs_scale',
    'minmax_scale',
    'label_binarize',
    'quantile_transform',
]

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

@carlomazzaferro The CategoricalEncoder class has been introduced recently and will only be released in version 0.20. So if you install scikit-learn directly from the git repository you’ll have it, otherwise, you’ll have to wait for the next release! 😄

You can have a look at the features that will be added in next release: here .

FWIW: pip install https://github.com/scikit-learn/scikit-learn/archive/master.zip is faster with the same result.

@Fern2018 pip install git+git://github.com/scikit-learn/scikit-learn.git from a terminal prompt should do it.

It’s also very possible that CategoricalEncoder will disappear again before the next release (see #10521)

On 3 February 2018 at 13:06, Carlo Mazzaferro notifications@github.com wrote:

Closed #10579 https://github.com/scikit-learn/scikit-learn/issues/10579.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/scikit-learn/scikit-learn/issues/10579#event-1456218540, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEz64lXyggCO1dG22buKmYG_9W35zR6ks5tQ78ogaJpZM4R31NB .