Search code examples
scikit-learnpycaret

Pycaret - 'Make_Time_Features' object has no attribute 'list_of_features'


I am trying to create a model using pycaret just as:

from pycaret.classification import *

clf1 = setup(data = dt, target = 'group')
lr = create_model('lr')

Then I get:

AttributeError: 'Simple_Imputer' object has no attribute 'fill_value_categorical'

So, following here, I added:

clf1 = setup(data = dt, target = 'group',  imputation_type='iterative' )
lr = create_model('lr')

Then I get:

AttributeError: 'Make_Time_Features' object has no attribute 'list_of_features'

My version of sklearn is 0.23.2 and pycaret is 2.3.2


Solution

  • You mentioned my previous question here.

    I just faced the same issue as you on Colab. It is 100% issue with libraries.

    Initially, I got the error for SMOTE:

    • `AttributeError: 'SMOTE' object has no attribute '_validate_data'

    After installing/reinstalling libraries I got exactly your error.

    How did I resolve it?

    • Started to run Colab and imported all common libraries (pd, np, scikit, etc).
    • Installed PyCaret via pip install. Then import pycaret and from pycaret.classification import *
    • Colab reacted: you have issues with scipy, sklearn, lightgbm, please restart your runtime.
    • Restarted my runtime on Colab
    • Imported all libraries again as I did in step 1
    • Ran import pycaret and from pycaret.classification import * only

    My final code:

    # Initialize the setup with SMOTE
    clf_smote = setup(
        data,
        session_id = 123,
        target = 'Target',
        remove_multicollinearity = True,
        multicollinearity_threshold = 0.95, 
        fix_imbalance = True
    )
    

    I did not use imputation_type='iterative' as in my question above.

    Proof of running:

    It worked, but it was my solution. Would be great to have a more detailed guide on how to deal with such issues, using this amazing library.