microsoft / FLAML

A fast library for AutoML and tuning. Join our Discord: https://discord.gg/Cppx2vSPVP.
https://microsoft.github.io/FLAML/
MIT License
3.75k stars 495 forks source link

name 'shuffle' is not defined #1308

Open flippercy opened 1 month ago

flippercy commented 1 month ago

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

The version of FLAML used is 2.1.2.

Thank you.

Programmer-RD-AI commented 1 month ago

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

ao-zz commented 3 weeks ago

@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

Programmer-RD-AI commented 3 weeks ago

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

thinkall commented 3 weeks ago

@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
ao-zz commented 3 weeks ago

@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.

thinkall commented 3 weeks ago

@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.