FLAML icon indicating copy to clipboard operation
FLAML copied to clipboard

name 'shuffle' is not defined

Open flippercy opened this issue 1 year ago • 6 comments
trafficstars

Got the error "name 'shuffle' is not defined" when running autoML.

The version of FLAML used is 2.1.2.

Thank you.

flippercy avatar May 22 '24 19:05 flippercy

Could you provide the entire error if possible? or the code to replicate?

Programmer-RD-AI avatar May 23 '24 08:05 Programmer-RD-AI

@Programmer-RD-AI My error message:

File "/xxx/python3.8/site-packages/flaml/automl/task/generic_task.py" , line 425, in prepare_data
    X_train_all, y_train_all = shuffle(X_train_all, y_train_all, random_state=RANDOM_SEED)
NameError: name 'shuffle' is not defined

I think it may need import random and use random.shuffle

ao-zz avatar Jun 06 '24 12:06 ao-zz

Hi, I will put up a PR for this issue ASAP

Programmer-RD-AI avatar Jun 06 '24 13:06 Programmer-RD-AI

@flippercy Looks like your scikit-learn is not working as expected. What do you see with below code:

    from sklearn.model_selection import (
        GroupKFold,
        GroupShuffleSplit,
        RepeatedKFold,
        RepeatedStratifiedKFold,
        StratifiedGroupKFold,
        TimeSeriesSplit,
        train_test_split,
    )
    from sklearn.utils import shuffle

thinkall avatar Jun 08 '24 15:06 thinkall

@thinkall Thanks for your hint. Error occurs when import StratifiedGroupKFold.

According to the change log of scikit-learn, model_selection.StratifiedGroupKFold is added in version 1.0, while the minimum version required by FLAML's setup.py is 0.24. After update scikit-learn to version 1.0, the error disappears.

And sorry for misleading @Programmer-RD-AI , I will check the reason for abnormal behaviors more carefully next time.

ao-zz avatar Jun 11 '24 01:06 ao-zz

@thinkall Thanks for your hint. Error occurs when import StratifiedGroupKFold.

According to the change log of scikit-learn, model_selection.StratifiedGroupKFold is added in version 1.0, while the minimum version required by FLAML's setup.py is 0.24. After update scikit-learn to version 1.0, the error disappears.

And sorry for misleading @Programmer-RD-AI , I will check the reason for abnormal behaviors more carefully next time.

Thank you @ao-zz for your feedback, looks like it's time to update the dependencies. I'm working on adding support to python 3.11, will update the dependencies accordingly.

thinkall avatar Jun 11 '24 12:06 thinkall

Fixed in #1326

thinkall avatar Aug 07 '24 02:08 thinkall