Pycaret分类.compare_models不显示结果网格

问题描述 投票:0回答:3

从 pycaret 的文档和教程中,我希望classification.compare_models()函数返回一个网格,例如......

型号 准确度 AUC 回忆 Prec. F1 河童 中冶集团 TT(秒)
0 朴素贝叶斯 0.9567 0.0000 0.9556 0.9619 0.9561 0.9348 0.9378 0.0076
1 K 邻居分类器 0.9467 0.0000 0.9444 0.9633 0.9430 0.9197 0.9295 0.0077
2 极端梯度提升 0.9467 0.0000 0.9444 0.9633 0.9430 0.9197 0.9295 0.0521

我的代码

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)

但我从来没有得到我所希望的网格。 我在 Windows 上的 Git Bash 中使用 Anaconda 运行 Python 3.8。

python pycaret
3个回答
6
投票

您可以尝试在

best = compare_models()

之后立即执行此操作
best = compare_models()

# Get you the results in a pandas dataframe (results object)
results = pull()

# Print out the results
print(results)

0
投票

在进一步研究中,我发现网格打印需要 IPython 支持 - 它不会在控制台文本中打印,

我通过在 jupyter 笔记本会话中运行代码获得了我正在寻找的输出。


0
投票

也许它有帮助,我遇到了同样的问题,直到我对我的数据应用了日志变换,在那一刻,值 0 变成了 inf 或 -inf 在那一刻,pycaret 提供的网格是空的[],当我将这些值 -inf 设置为 0 时,网格出现 希望有帮助

© www.soinside.com 2019 - 2024. All rights reserved.