Skip to content
Advertisement

Pycaret classification.compare_models does not display results grid

From the documentation and tutorials for pycaret, I expect the classification.compare_models() function to return a grid such as…

Model Accuracy AUC Recall Prec. F1 Kappa MCC TT (Sec)
0 Naive Bayes 0.9567 0.0000 0.9556 0.9619 0.9561 0.9348 0.9378 0.0076
1 K Neighbors Classifier 0.9467 0.0000 0.9444 0.9633 0.9430 0.9197 0.9295 0.0077
2 Extreme Gradient Boosting 0.9467 0.0000 0.9444 0.9633 0.9430 0.9197 0.9295 0.0521
etc.

My code

from pycaret.classification import *
import pandas as pd

df = pd.read_csv('input.csv')
setup_result = setup(data=df, target='Class')
best = compare_models()
print(best)

I get lot’s of output like this…

Initiated  . . . . . . . . . . . . . . . . . .              11:35:34
Status     . . . . . . . . . . . . . . . . . .  Loading Dependencies
Estimator  . . . . . . . . . . . . . . . . . .     Compiling Library
Empty DataFrame
Columns: [Model, Accuracy, AUC, Recall, Prec., F1, Kappa, MCC, TT (Sec)]
Index: []                                                     
                                                                 
Initiated  . . . . . . . . . . . . . . . . . .           11:35:34
Status     . . . . . . . . . . . . . . . . . .  Loading Estimator
Estimator  . . . . . . . . . . . . . . . . . .  Compiling Library
                                                                 
                                                                 
Initiated  . . . . . . . . . . . . . . . . . .           11:35:34
Status     . . . . . . . . . . . . . . . . . .  Loading Estimator
Estimator  . . . . . . . . . . . . . . . . . .  Compiling Library

And this at the end…

Initiated                         11:35:34  
Status              Compiling Final Models  
Estimator  Light Gradient Boosting Machine  

<pandas.io.formats.style.Styler object at 0x000002562E9A6B20>
LGBMClassifier(boosting_type='gbdt', class_weight=None, colsample_bytree=1.0,
               device='gpu', importance_type='split', learning_rate=0.1,
               max_depth=-1, min_child_samples=20, min_child_weight=0.001,
               min_split_gain=0.0, n_estimators=100, n_jobs=-1, num_leaves=31,
               objective=None, random_state=123, reg_alpha=0.0, reg_lambda=0.0,
               silent='warn', subsample=1.0, subsample_for_bin=200000,
               subsample_freq=0)

But I never get the grid I’m hoping for. I’m running Python 3.8 with Anaconda in Git Bash on Windows.

Advertisement

Answer

On further research I found that IPython support is required for the grid to print – it will not print in console text,

I got the output I was looking for by running the code in a jupyter notebook session.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement