title: Using a LabelEncoder in sklearn's Pipeline gives: fit_transform takes 2 positional arguments but 3 were given
body: <p>I've been trying to run some ML code but I keep faltering at the fitting stage after running my pipeline. I've looked around on various forums to not much avail. What I've discovered is that some people say you can't use LabelEncoder within a pipeline. I'm not sure how true that is. If anyone has any insights on the matter I'd be very happy to hear them.</p>
  <p>I keep getting this error:</p>
  <pre><code>TypeError: fit_transform() takes 2 positional arguments but 3 were given
  </code></pre>
  <p>And so I'm not sure if the problem is from me or from python. Here's my code:</p>
  <pre><code>data = pd.read_csv(&quot;ks-projects-201801.csv&quot;,
                     index_col=&quot;ID&quot;,
                     parse_dates=[&quot;deadline&quot;,&quot;launched&quot;],
                     infer_datetime_format=True)
  
  var = list(data)
  
  data = data.drop(labels=[1014746686,1245461087, 1384087152, 1480763647, 330942060, 462917959, 69489148])
  missing = [i for i in var if data[i].isnull().any()]
  data = data.dropna(subset=missing,axis=0)
  le = LabelEncoder()
  oe = OrdinalEncoder()
  oh = OneHotEncoder()
  y = [i for i in var if i==&quot;state&quot;]
  y = data[var.pop(8)]
  
  p,p.index = pd.Series(le.fit_transform(y)),y.index
  q = pd.read_csv(&quot;y.csv&quot;,index_col=&quot;ID&quot;)[&quot;0&quot;]
  label_y = le.fit_transform(y)
  
  x = data[var]
  
  obj_feat = x.select_dtypes(include=&quot;object&quot;)
  dat_feat = x.select_dtypes(include=&quot;datetime64[ns]&quot;)
  dat_feat = dat_feat.assign(dmonth=dat_feat.deadline.dt.month.astype(&quot;int64&quot;),
                             dyear = dat_feat.deadline.dt.year.astype(&quot;int64&quot;),
                             lmonth=dat_feat.launched.dt.month.astype(&quot;int64&quot;),
                             lyear=dat_feat.launched.dt.year.astype(&quot;int64&quot;))
  dat_feat = dat_feat.drop(labels=[&quot;deadline&quot;,&quot;launched&quot;],axis=1)
  num_feat = x.select_dtypes(include=[&quot;int64&quot;,&quot;float64&quot;])
  
  u = dict(zip(list(obj_feat),[len(obj_feat[i].unique()) for i in obj_feat]))
  le_obj = [i for i in u if u[i]&lt;10]
  oh_obj = [i for i in u if u[i]&lt;20 and u[i]&gt;10]
  te_obj = [i for i in u if u[i]&gt;20 and u[i]&lt;25]
  cb_obj = [i for i in u if u[i]&gt;100]
  
  # Pipeline time
  #Impute and encode
  
  strat = [&quot;constant&quot;,&quot;most_frequent&quot;,&quot;mean&quot;,&quot;median&quot;]
  sc = StandardScaler()
  oh_unk = &quot;ignore&quot;
  encoders = [LabelEncoder(),
              OneHotEncoder(handle_unknown=oh_unk),
              TargetEncoder(),
              CatBoostEncoder()]
  
  #num_trans = Pipeline(steps=[(&quot;imp&quot;,SimpleImputer(strategy=strat[2])),
  num_trans = Pipeline(steps=[(&quot;sc&quot;,sc)])
  #obj_imp = Pipeline(steps=[(&quot;imp&quot;,SimpleImputer(strategy=strat[1]))])
  oh_enc = Pipeline(steps=[(&quot;oh_enc&quot;,encoders[1])])
  te_enc = Pipeline(steps=[(&quot;te_enc&quot;,encoders[2])])
  cb_enc = Pipeline(steps=[(&quot;cb_enc&quot;,encoders[0])])
  
  trans = ColumnTransformer(transformers=[
                                          (&quot;num&quot;,num_trans,list(num_feat)+list(dat_feat)),
                                          #(&quot;obj&quot;,obj_imp,list(obj_feat)),
                                          (&quot;onehot&quot;,oh_enc,oh_obj),
                                          (&quot;target&quot;,te_enc,te_obj),
                                          (&quot;catboost&quot;,cb_enc,cb_obj)
                                          ])
  
  models = [RandomForestClassifier(random_state=0),
            KNeighborsClassifier(),
            DecisionTreeClassifier(random_state=0)]
  
  model = models[2]
  
  print(&quot;Check 4&quot;)
  
  # Chaining it all together
  run = Pipeline(steps=[(&quot;Transformation&quot;,trans),(&quot;Model&quot;,model)])
  
  x = pd.concat([obj_feat,dat_feat,num_feat],axis=1)
  print(&quot;Check 5&quot;)
  run.fit(x,p)
  </code></pre>
  <p>It runs fine until run.fit where it throws an error. I'd love to hear any advice anyone might have, and any possible ways to resolve this problem would also be greatly appreciated! Thank you.</p>