<h4 dir="auto">Description</h4>
<p dir="auto">fit and fit_transform methods in LabelEncoder don't follow the standard scikit-lean convention for these methods: fit(X[, y]) and fit_transform(X[, y]). The fit and fit_transform method in the LabelEncoder only accepts one argument: fit(y) and fit_transform(y).</p>
<p dir="auto">Therefore, LabelEncoder couldn't be used inside a Pipeline or a ColumnTransform. I suspect that there are a bunch of other classes in which it doesn't work (GridSearchCV, ...) but I haven't tested it.</p>
<p dir="auto">In contrast, fit and fit_transform methods in OneHotEncoder and OrdinalEncoder follows the standard scikit-learn signature.</p>
<p dir="auto">See reference:<br>
LabelEncoder: <a href="https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.LabelEncoder.html" rel="nofollow">https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.LabelEncoder.html</a><br>
OneHotEnconder: <a href="https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html#sklearn.preprocessing.OneHotEncoder" rel="nofollow">https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html#sklearn.preprocessing.OneHotEncoder</a><br>
OrdinalEncoder:<a href="https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OrdinalEncoder.html#sklearn.preprocessing.OrdinalEncoder" rel="nofollow">https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OrdinalEncoder.html#sklearn.preprocessing.OrdinalEncoder</a></p>
<h4 dir="auto">Steps/Code to Reproduce</h4>
<p dir="auto">Example:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas as pd

from sklearn.preprocessing import LabelEncoder
from sklearn.pipeline import make_pipeline
from sklearn.compose import ColumnTransformer
import sklearn.tree as tree

X = pd.DataFrame(
    {'city': ['London', 'London', 'Paris', 'Sallisaw'],
     'title': [&quot;His Last Bow&quot;, &quot;How Watson Learned the Trick&quot;,
               &quot;A Moveable Feast&quot;, &quot;The Grapes of Wrath&quot;],
     'expert_rating': [5, 3, 4, 5],
     'user_rating': [4, 5, 4, 3]})

column_trans = ColumnTransformer(
    [('title_bow', LabelEncoder(), 'title')],
    remainder='drop').fit(X)

pipe = make_pipeline(LabelEncoder(), tree.DecisionTreeClassifier()).fit(X)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>

<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">preprocessing</span> <span class="pl-k">import</span> <span class="pl-v">LabelEncoder</span>
<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">pipeline</span> <span class="pl-k">import</span> <span class="pl-s1">make_pipeline</span>
<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">compose</span> <span class="pl-k">import</span> <span class="pl-v">ColumnTransformer</span>
<span class="pl-k">import</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">tree</span> <span class="pl-k">as</span> <span class="pl-s1">tree</span>

<span class="pl-v">X</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(
    {<span class="pl-s">'city'</span>: [<span class="pl-s">'London'</span>, <span class="pl-s">'London'</span>, <span class="pl-s">'Paris'</span>, <span class="pl-s">'Sallisaw'</span>],
     <span class="pl-s">'title'</span>: [<span class="pl-s">"His Last Bow"</span>, <span class="pl-s">"How Watson Learned the Trick"</span>,
               <span class="pl-s">"A Moveable Feast"</span>, <span class="pl-s">"The Grapes of Wrath"</span>],
     <span class="pl-s">'expert_rating'</span>: [<span class="pl-c1">5</span>, <span class="pl-c1">3</span>, <span class="pl-c1">4</span>, <span class="pl-c1">5</span>],
     <span class="pl-s">'user_rating'</span>: [<span class="pl-c1">4</span>, <span class="pl-c1">5</span>, <span class="pl-c1">4</span>, <span class="pl-c1">3</span>]})

<span class="pl-s1">column_trans</span> <span class="pl-c1">=</span> <span class="pl-v">ColumnTransformer</span>(
    [(<span class="pl-s">'title_bow'</span>, <span class="pl-v">LabelEncoder</span>(), <span class="pl-s">'title'</span>)],
    <span class="pl-s1">remainder</span><span class="pl-c1">=</span><span class="pl-s">'drop'</span>).<span class="pl-en">fit</span>(<span class="pl-v">X</span>)

<span class="pl-s1">pipe</span> <span class="pl-c1">=</span> <span class="pl-en">make_pipeline</span>(<span class="pl-v">LabelEncoder</span>(), <span class="pl-s1">tree</span>.<span class="pl-v">DecisionTreeClassifier</span>()).<span class="pl-en">fit</span>(<span class="pl-v">X</span>)</pre></div>
<h4 dir="auto">Expected Results</h4>
<p dir="auto">No error is thrown.</p>
<h4 dir="auto">Actual Results</h4>
<p dir="auto">The same error in both cases:<br>
TypeError: fit_transform() takes 2 positional arguments but 3 were given.</p>
<h4 dir="auto">Versions</h4>
<p dir="auto">System:<br>
python: 3.6.6 |Anaconda, Inc.| (default, Oct  9 2018, 12:34:16)  [GCC 7.3.0]<br>
executable: /home/twins/anaconda3/envs/pytorch/bin/python<br>
machine: Linux-4.8.0-56-generic-x86_64-with-debian-stretch-sid</p>
<p dir="auto">BLAS:<br>
macros: SCIPY_MKL_H=None, HAVE_CBLAS=None<br>
lib_dirs: /home/twins/anaconda3/envs/pytorch/lib<br>
cblas_libs: mkl_rt, pthread</p>
<p dir="auto">Python deps:<br>
pip: 18.1<br>
setuptools: 40.6.2<br>
sklearn: 0.20.1<br>
numpy: 1.15.4<br>
scipy: 1.1.0<br>
Cython: None<br>
pandas: 0.23.4</p>
<p dir="auto">Thanks for the amazing job you do !</p>
<p dir="auto">I've found that I cannot use pipelines if I wish to use the label encoder. In the following I wish to build a pipeline that first encodes the label and then constructs a one-hot encoding from that labelling.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from sklearn.preprocessing import  OneHotEncoder, LabelEncoder
from sklearn.pipeline import make_pipeline
import numpy as np

X = np.array(['cat', 'dog', 'cow', 'cat', 'cow', 'dog'])

enc = LabelEncoder()
hot = OneHotEncoder()

pipe = make_pipeline(enc, hot)
pipe.fit_transform(X)"><pre class="notranslate"><code class="notranslate">from sklearn.preprocessing import  OneHotEncoder, LabelEncoder
from sklearn.pipeline import make_pipeline
import numpy as np

X = np.array(['cat', 'dog', 'cow', 'cat', 'cow', 'dog'])

enc = LabelEncoder()
hot = OneHotEncoder()

pipe = make_pipeline(enc, hot)
pipe.fit_transform(X)
</code></pre></div>
<p dir="auto">However, the following error is returned:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="lib/python2.7/site-packages/sklearn/pipeline.pyc in _pre_transform(self, X, y, **fit_params)
    117         for name, transform in self.steps[:-1]:
    118             if hasattr(transform, &quot;fit_transform&quot;):
--&gt; 119                 Xt = transform.fit_transform(Xt, y, **fit_params_steps[name])
    120             else:
    121                 Xt = transform.fit(Xt, y, **fit_params_steps[name]) \

TypeError: fit_transform() takes exactly 2 arguments (3 given)"><pre class="notranslate"><code class="notranslate">lib/python2.7/site-packages/sklearn/pipeline.pyc in _pre_transform(self, X, y, **fit_params)
    117         for name, transform in self.steps[:-1]:
    118             if hasattr(transform, "fit_transform"):
--&gt; 119                 Xt = transform.fit_transform(Xt, y, **fit_params_steps[name])
    120             else:
    121                 Xt = transform.fit(Xt, y, **fit_params_steps[name]) \

TypeError: fit_transform() takes exactly 2 arguments (3 given)
</code></pre></div>
<p dir="auto">It seems that the problem is that the fit method for label encoder only takes a y argument, whereas the pipeline assumes that it will take an X and an optional y.</p>