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
JavaScript
x
8
1
from pycaret.classification import *
2
import pandas as pd
3
4
df = pd.read_csv('input.csv')
5
setup_result = setup(data=df, target='Class')
6
best = compare_models()
7
print(best)
8
I get lot’s of output like this…
JavaScript
1
16
16
1
Initiated . . . . . . . . . . . . . . . . . . 11:35:34
2
Status . . . . . . . . . . . . . . . . . . Loading Dependencies
3
Estimator . . . . . . . . . . . . . . . . . . Compiling Library
4
Empty DataFrame
5
Columns: [Model, Accuracy, AUC, Recall, Prec., F1, Kappa, MCC, TT (Sec)]
6
Index: []
7
8
Initiated . . . . . . . . . . . . . . . . . . 11:35:34
9
Status . . . . . . . . . . . . . . . . . . Loading Estimator
10
Estimator . . . . . . . . . . . . . . . . . . Compiling Library
11
12
13
Initiated . . . . . . . . . . . . . . . . . . 11:35:34
14
Status . . . . . . . . . . . . . . . . . . Loading Estimator
15
Estimator . . . . . . . . . . . . . . . . . . Compiling Library
16
And this at the end…
JavaScript
1
13
13
1
Initiated 11:35:34
2
Status Compiling Final Models
3
Estimator Light Gradient Boosting Machine
4
5
<pandas.io.formats.style.Styler object at 0x000002562E9A6B20>
6
LGBMClassifier(boosting_type='gbdt', class_weight=None, colsample_bytree=1.0,
7
device='gpu', importance_type='split', learning_rate=0.1,
8
max_depth=-1, min_child_samples=20, min_child_weight=0.001,
9
min_split_gain=0.0, n_estimators=100, n_jobs=-1, num_leaves=31,
10
objective=None, random_state=123, reg_alpha=0.0, reg_lambda=0.0,
11
silent='warn', subsample=1.0, subsample_for_bin=200000,
12
subsample_freq=0)
13
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.