I'm trying to use the sklearn_pandas module to extend the work I do in pandas and dip a toe into machine learning but I'm struggling with an error I don't really understand how to fix.I was working through the following dataset on Kaggle.It's essentially an unheadered table (1000 rows, 40 features) with floating point values.import pandas as pdfrom sklearn import neighborsfrom sklearn_pandas import DataFrameMapper, cross_val_scorepath_train =../kaggle/scikitlearn/train.csvpath_labels =../kaggle/scikitlearn/trainLabels.csvpath_test = ../kaggle/scikitlearn/test.csvtrain = pd.read_csv(path_train, header=None)labels = pd.read_csv(path_labels, header=None)test = pd.read_csv(path_test, header=None)mapper_train = DataFrameMapper([(list(train.columns),neighbors.KNeighborsClassifier(n_neighbors=3))])mapper_trainOutput:DataFrameMapper(features=[([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',       n_neighbors=3, p=2, weights='uniform'))])So far so good. But then I try the fitmapper_train.fit_transform(train, labels)Output:---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last)<ipython-input-6-e3897d6db1b5> in <module>()----> 1 mapper_train.fit_transform(train, labels)//anaconda/lib/python2.7/site-packages/sklearn/base.pyc in fit_transform(self, X, y,     **fit_params)    409         else:    410             # fit method of arity 2 (supervised transformation)--> 411             return self.fit(X, y, **fit_params).transform(X)    412     413 //anaconda/lib/python2.7/site-packages/sklearn_pandas/__init__.pyc in fit(self, X, y)    116         for columns, transformer in self.features:    117             if transformer is not None:--> 118                 transformer.fit(self._get_col_subset(X, columns))    119         return self    120 TypeError: fit() takes exactly 3 arguments (2 given)`What am I doing wrong? While the data in this case is all the same, I'm planning to work up a workflow for mixtures categorical, nominal and floating point features and sklearn_pandas seemed to be a logical fit.
Struggling to integrate sklearn and pandas in simple Kaggle task
python;pandas;scikit learn
Here is an example of how to get pandas and sklearn to play nice say you have 2 columns that are both strings and you wish to vectorize - but you have no idea which vectorization params will result in the best downstream performance.create the vectorizer to_vect = Pipeline([('vect',CountVectorizer(min_df =1,max_df=.9,ngram_range=(1,2),max_features=1000)),                    ('tfidf', TfidfTransformer())])create the DataFrameMapper obj.full_mapper = DataFrameMapper([        ('col_name1', to_vect),        ('col_name2',to_vect)    ])this is the full pipelinefull_pipeline  = Pipeline([('mapper',full_mapper),('clf', SGDClassifier(n_iter=15, warm_start=True))])define the params you want the scan to considerfull_params = {'clf__alpha': [1e-2,1e-3,1e-4],                   'clf__loss':['modified_huber','hinge'],                   'clf__penalty':['l2','l1'],                   'mapper__features':[[('col_name1',deepcopy(to_vect)),                                        ('col_name2',deepcopy(to_vect))],                                       [('col_name1',deepcopy(to_vect).set_params(vect__analyzer= 'char_wb')),                                        ('col_name2',deepcopy(to_vect))]]}Thats it! - note however that mapper_features are a single item in this dictionary - so use a for loop or itertools.product to generate a FLAT list of all to_vect options you wish to consider - but that is a separate task outside the scope of the question.Go on to create the optimal classifier or whatever else your pipeline ends withgs_clf = GridSearchCV(full_pipe, full_params, n_jobs=-1)