question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name 'CategoricalEncoder'

See original GitHub issue

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',
]

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
maskani-mohcommented, Feb 3, 2018

@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 .

2reactions
jnothmancommented, Mar 29, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Categorical Encoder in Scikit Learn Preprocessing
I was trying to import Categorical Encoder in sklearn
Read more >
scikit-learn - Gitter
Hello all, I want to take up a moderate issue or something significant not currently being worked upon by anyone. Is there an...
Read more >
scikit-learn, NameError: name 'CategoricalEncoder' is not ...
ImportError: cannot import name 'CategoricalEncoder' · Issue #10579 · scikit-learn/scikit-learn. As simple as that.
Read more >
[Scikit-learn] ImportError: cannot import name ... - Mizys
ImportError: cannot import name 'CategoricalEncoder' from 'sklearn.preprocessing' · Issue #14402 · scikit-learn/scikit-learn.
Read more >
from sklearn.preprocessing import LabalEncoder Code Example
from sklearn.preprocessing import LabelEncoder le ... import classification_report · ImportError: cannot import name 'joblib' from ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found