Skip to content

Instantly share code, notes, and snippets.

@paulgb
Created March 24, 2013 17:20
Show Gist options
  • Save paulgb/5232709 to your computer and use it in GitHub Desktop.
Save paulgb/5232709 to your computer and use it in GitHub Desktop.
from sklearn import preprocessing, pipeline
label_enc = preprocessing.LabelEncoder()
pipe = pipeline.Pipeline([('enc', label_enc)])
X = ['foo', 'bar', 'baz']
label_enc.fit(X) # works
pipe.fit(X) # fails w/ output below
'''
Output:
Traceback (most recent call last):
File "pipetest.py", line 9, in <module>
pipe.fit(X)
File "/Library/Python/2.7/site-packages/sklearn/pipeline.py", line 128, in fit
self.steps[-1][-1].fit(Xt, y, **fit_params)
TypeError: fit() takes exactly 2 arguments (3 given)
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment