pycaret / pycaret

An open-source, low-code machine learning library in Python
https://www.pycaret.org
MIT License
8.95k stars 1.77k forks source link

KeyError: 'Only the Series name can be used for the key in Series dtype mappings.' #339

Open chamsdg opened 4 years ago

chamsdg commented 4 years ago

hello when i applies fix_imbalance = True for my dataset churn

and i do model = compare_models() i get the below error

KeyError: 'Only the Series name can be used for the key in Series dtype mappings.'

somebody can help me

pycaret commented 4 years ago

@chamsdg Please provide complete traceback message. Environment you are using, sample code and dataset if possible.

chamsdg commented 4 years ago

@pycaret i work in windows using jypyterLab my code is bellow:

from pycaret.classification import * train = setup(data, target = 'Exited', train_size = 0.8, fix_imbalance = True, fix_imbalance_method = None, session_id = 123, log_experiment = True, experiment_name="churn")

when i want to compare the performance

best_model = compare_models()

i get this error

`KeyError Traceback (most recent call last)

in ----> 1 best_model = compare_models() C:\ProgramData\Anaconda3\lib\site-packages\pycaret\classification.py in compare_models(blacklist, whitelist, fold, round, sort, n_select, turbo, verbose) 4929 resampler = fix_imbalance_method_param 4930 -> 4931 Xtrain,ytrain = resampler.fit_sample(Xtrain, ytrain) 4932 logger.info(Resampling completed) 4933 C:\ProgramData\Anaconda3\lib\site-packages\imblearn\base.py in fit_resample(self, X, y) 86 if binarize_y else output[1]) 87 ---> 88 X_, y_ = arrays_transformer.transform(output[0], y_) 89 return (X_, y_) if len(output) == 2 else (X_, y_, output[2]) 90 C:\ProgramData\Anaconda3\lib\site-packages\imblearn\utils\_validation.py in transform(self, X, y) 38 39 def transform(self, X, y): ---> 40 X = self._transfrom_one(X, self.x_props) 41 y = self._transfrom_one(y, self.y_props) 42 return X, y C:\ProgramData\Anaconda3\lib\site-packages\imblearn\utils\_validation.py in _transfrom_one(self, array, props) 57 import pandas as pd 58 ret = pd.DataFrame(array, columns=props[columns]) ---> 59 ret = ret.astype(props[dtypes]) 60 elif type_ == series: 61 import pandas as pd C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py in astype(self, dtype, copy, errors, **kwargs) 5863 results.append( 5864 col.astype( -> 5865 dtype=dtype[col_name], copy=copy, errors=errors, **kwargs 5866 ) 5867 ) C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py in astype(self, dtype, copy, errors, **kwargs) 5846 if len(dtype) > 1 or self.name not in dtype: 5847 raise KeyError( -> 5848 Only the Series name can be used for 5849 the key in Series dtype mappings. 5850 ) KeyError: Only the Series name can be used for the key in Series dtype mappings.` my dataset ![dataset](https://user-images.githubusercontent.com/50946856/89276896-75299100-d644-11ea-9227-1bb440b9ed21.PNG)
pycaret commented 4 years ago

@chamsdg Can you please submit logs.log file that is generated in your local directory. This will help me troubleshoot.

Can you try creating a conda environment and see if the error goes away? You can follow instructions on https://www.pycaret.org/install if you want.

chamsdg commented 4 years ago

@pycaret find below the file log

logs.log

chamsdg commented 4 years ago

hello, any help please

hyunjoonbok commented 4 years ago

I'm having the same error message KeyError: 'Only the Series name can be used for the key in Series dtype mappings.'

Any updates on this yet? Appreciates it in advance.

hyunjoonbok commented 4 years ago

Based on below link, it looks like SMOTE has to take in dataframe as a matrix https://datascience.stackexchange.com/questions/66302/resampling-with-python-smote

pycaret commented 4 years ago

@chamsdg Can you please share the dataset here? I have looked at logs and it seems like it's failing when SMOTE is initialized however I don't see anything funny with the setup so I need dataset to reproduce this issue at my end.

Also can you please share the version of imblearn by doing pip freeze.

Thanks

chamsdg commented 4 years ago

thank you

github-actions[bot] commented 3 years ago

Stale issue message: This issue will be automatically closed by GitHub Actions in 1 week if there is no further activity.