Pycaret classification.compare_models 不显示结果网格
Pycaret classification.compare_models does not display results grid
从 pycaret 的文档和教程中,我希望 classification.compare_models() 函数能够 return 网格,例如...
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.
我的代码
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)
我得到很多这样的输出...
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
最后这个...
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)
但我从来没有得到我希望的网格。
我是 运行 Python 3.8,Anaconda 在 Git Bash Windows.
在进一步的研究中,我发现 IPython 网格需要支持才能打印 - 它不会在控制台文本中打印,
我通过 运行 jupyter notebook 会话中的代码得到了我正在寻找的输出。
您可以尝试在 best = compare_models()
之后立即执行此操作
best = compare_models()
# Get you the results in a pandas dataframe (results object)
results = pull()
从 pycaret 的文档和教程中,我希望 classification.compare_models() 函数能够 return 网格,例如...
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. |
我的代码
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)
我得到很多这样的输出...
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
最后这个...
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)
但我从来没有得到我希望的网格。 我是 运行 Python 3.8,Anaconda 在 Git Bash Windows.
在进一步的研究中,我发现 IPython 网格需要支持才能打印 - 它不会在控制台文本中打印,
我通过 运行 jupyter notebook 会话中的代码得到了我正在寻找的输出。
您可以尝试在 best = compare_models()
best = compare_models()
# Get you the results in a pandas dataframe (results object)
results = pull()