2

pycaret 是一个非常紧凑的工具,用于比较我想用于模型选择的模型。不幸的是,compare_models 方法没有显示您随处可见的典型输出表。我在 PyCharm 中使用 pycaret 而不是 Jupyter Notebook,这似乎是典型的方法。我确实得到了最好的模型作为返回值,但我的目标是概览表。silent是否将参数设置为TrueFalse要求确认派生数据类型是否正确似乎也没有区别。

非常感谢你!

系统:Python 3.6 pycaret 2.3 CentOS 7 PyCharm 2020.1 社区版

我的代码:

    regression.setup(data=ml_df,
                     target='occupation',
                     n_jobs=6,
                     categorical_features=['cluster', 'vacation', 'long_weekend', 'month', 'hour', 'weekday'],
                     numeric_features=['temperature', 'precipitation'],
                     silent=False
                     )
    best_regression_models = regression.compare_models()

    categorisation = [
        [-0.1, 'empty'],
        [0.01, 'partial'],
        [0.99, 'full']
    ]
    ml_df['occupation'] = modelling_utils.convert_number_to_categorical(ml_df['occupation'], categorisation)
    classification.setup(data=ml_df,
                         target='occupation',
                         n_jobs=6,
                         categorical_features=['cluster', 'vacation', 'long_weekend', 'month', 'hour', 'weekday'],
                         numeric_features=['temperature', 'precipitation'],
                         fix_imbalance=True,
                         silent=False)
    best_classification_models = classification.compare_models()

完整的输出有点长,保存在这里

编辑:代码在 Jupyter Notebook 中按预期工作

4

1 回答 1

4

与从 Jupyter 笔记本运行相比,从终端/命令行运行 PyCaret 具有不同的行为。在您的情况下,如果要显示比较输出表,请在 compare_models() 函数调用之后添加以下两行:

..
best_regression_models = regression.compare_models()


regression_results = pull()
print(regression_results)

pull() 函数还将返回带有其他训练函数的最后一个分数网格,例如 create_model()。目前此功能仅适用于回归和分类模块。

参考:https ://pycaret.org/pull/

于 2021-05-30T04:31:16.347 回答