New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pandas version: TypeError: drop() got an unexpected keyword argument 'columns' #14

Closed
salma1601 opened this Issue May 8, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@salma1601
Copy link

salma1601 commented May 8, 2018

Hi,
I am trying to run the starting kit but got the following error for the evaluation function

results = evaluation(data_train, labels_train)
>
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-1247bf8432df> in <module>()
----> 1 results = evaluation(data_train, labels_train)
      2 
      3 print("Training score ROC-AUC: {:.3f} +- {:.3f}".format(np.mean(results['train_roc_auc']),
      4                                                         np.std(results['train_roc_auc'])))
      5 print("Validation score ROC-AUC: {:.3f} +- {:.3f} \n".format(np.mean(results['test_roc_auc']),

<ipython-input-17-e7b8911b304f> in evaluation(X, y)
      8     results = cross_validate(pipe, X, y, scoring=['roc_auc', 'accuracy'], cv=cv,
      9                              verbose=1, return_train_score=True,
---> 10                              n_jobs=1)
     11 
     12     return results

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/model_selection/_validation.pyc in cross_validate(estimator, X, y, groups, scoring, cv, n_jobs, verbose, fit_params, pre_dispatch, return_train_score)
    204             fit_params, return_train_score=return_train_score,
    205             return_times=True)
--> 206         for train, test in cv.split(X, y, groups))
    207 
    208     if return_train_score:

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __call__(self, iterable)
    777             # was dispatched. In particular this covers the edge
    778             # case of Parallel used with an exhausted iterator.
--> 779             while self.dispatch_one_batch(iterator):
    780                 self._iterating = True
    781             else:

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in dispatch_one_batch(self, iterator)
    623                 return False
    624             else:
--> 625                 self._dispatch(tasks)
    626                 return True
    627 

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in _dispatch(self, batch)
    586         dispatch_timestamp = time.time()
    587         cb = BatchCompletionCallBack(dispatch_timestamp, len(batch), self)
--> 588         job = self._backend.apply_async(batch, callback=cb)
    589         self._jobs.append(job)
    590 

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/_parallel_backends.pyc in apply_async(self, func, callback)
    109     def apply_async(self, func, callback=None):
    110         """Schedule a func to be run"""
--> 111         result = ImmediateResult(func)
    112         if callback:
    113             callback(result)

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/_parallel_backends.pyc in __init__(self, batch)
    330         # Don't delay the application, to avoid keeping the input
    331         # arguments in memory
--> 332         self.results = batch()
    333 
    334     def get(self):

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __call__(self)
    129 
    130     def __call__(self):
--> 131         return [func(*args, **kwargs) for func, args, kwargs in self.items]
    132 
    133     def __len__(self):

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/model_selection/_validation.pyc in _fit_and_score(estimator, X, y, scorer, train, test, verbose, parameters, fit_params, return_train_score, return_parameters, return_n_test_samples, return_times, error_score)
    456             estimator.fit(X_train, **fit_params)
    457         else:
--> 458             estimator.fit(X_train, y_train, **fit_params)
    459 
    460     except Exception as e:

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/pipeline.pyc in fit(self, X, y, **fit_params)
    246             This estimator
    247         """
--> 248         Xt, fit_params = self._fit(X, y, **fit_params)
    249         if self._final_estimator is not None:
    250             self._final_estimator.fit(Xt, y, **fit_params)

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/pipeline.pyc in _fit(self, X, y, **fit_params)
    211                 Xt, fitted_transformer = fit_transform_one_cached(
    212                     cloned_transformer, None, Xt, y,
--> 213                     **fit_params_steps[name])
    214                 # Replace the transformer of the step with the fitted
    215                 # transformer. This is necessary when loading the transformer

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/memory.pyc in __call__(self, *args, **kwargs)
    360 
    361     def __call__(self, *args, **kwargs):
--> 362         return self.func(*args, **kwargs)
    363 
    364     def call_and_shelve(self, *args, **kwargs):

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/pipeline.pyc in _fit_transform_one(transformer, weight, X, y, **fit_params)
    579                        **fit_params):
    580     if hasattr(transformer, 'fit_transform'):
--> 581         res = transformer.fit_transform(X, y, **fit_params)
    582     else:
    583         res = transformer.fit(X, y, **fit_params).transform(X)

/home/salma/anaconda2/lib/python2.7/site-packages/sklearn/base.pyc in fit_transform(self, X, y, **fit_params)
    518         else:
    519             # fit method of arity 2 (supervised transformation)
--> 520             return self.fit(X, y, **fit_params).transform(X)
    521 
    522 

<ipython-input-18-6d322cc43f0d> in transform(self, X_df)
     10         # get only the anatomical information
     11         X = X_df[[col for col in X_df.columns if col.startswith('anatomy')]]
---> 12         return X.drop(columns='anatomy_select')

TypeError: drop() got an unexpected keyword argument 'columns'
@glemaitre

This comment has been minimized.

Copy link
Contributor

glemaitre commented May 8, 2018

I assume that you have a older version of pandas. columns has been added in pandas 0.21.
Can you update to the last release of pandas (0.22)

pip install -U pandas
conda update pandas

@glemaitre glemaitre added the answered label May 8, 2018

@salma1601

This comment has been minimized.

Copy link

salma1601 commented May 8, 2018

Yes now it works. Thanks !

@glemaitre glemaitre added the bug label May 8, 2018

@glemaitre glemaitre changed the title starting_kit: evalution function throws an error Pandas version: TypeError: drop() got an unexpected keyword argument 'columns' May 8, 2018

@aboucaud

This comment has been minimized.

Copy link

aboucaud commented May 9, 2018

@glemaitre, if you're using this new pandas feature in the kit, should we not put a minversion requirement in the requirements.txt and environment.yml ?

@aboucaud aboucaud reopened this May 9, 2018

@glemaitre glemaitre closed this May 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment