timetime-seriesforecastingpycaretmultivariate-time-series

PyCaret v3.0 - _CURRENT_EXPERIMENT global variable is not set


We are getting the following error after running either check_stats() or compare_models() functions from PyCaret versiob 3.0.x;

"_CURRENT_EXPERIMENT global variable is not set. Please run setup() first."

Is there any pointer that how this can be resolved?

Regards

Adil

i had run the check_stats() function, it gave me the same as mentioned above, further when i had run the compare_model() function, it also gave me the same error. Although when i see the documentation, it had clearly shown the output in the form of pandas dataframe


Solution

  • From your error, that means you didn't run the setup() step. So you need to run setup() first. PyCaret will do something behind the scene (preprocess, train/test split, etc.) with the data that you provide then you can do compare_models(), check_stats(), etc. You can learn more about PyCaret with Time Series from the official tutorial here

    from pycaret.datasets import get_data
    from pycaret.time_series import TSForecastingExperiment
    
    # Get sample data
    y = get_data('airline', verbose=False)
    
    # Setup Experiment
    exp = TSForecastingExperiment()
    exp.setup(data=y, fh=12)
    
    # Diagnostics plot (acf, pacf, qq-plot, etc.)
    exp.plot_model(plot='diagnostics')  
    
    # Check Statisticals Test
    exp.check_stats()
    
    # Compare Models
    best = exp.compare_models()