【问题标题】:Pycaret.regression.compare_models: Evaluation table neither returned nor shownPycaret.regression.compare_models:评估表既不返回也不显示
【发布时间】:2021-04-20 07:56:11
【问题描述】:

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

非常感谢!

系统: 蟒蛇 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()

完整的输出有点长,保存here

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

【问题讨论】:

    标签: python-3.x pycaret


    【解决方案1】:

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

    ..
    best_regression_models = regression.compare_models()
    
    
    regression_results = pull()
    print(regression_results)
    

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-01
      • 2015-10-05
      • 1970-01-01
      • 1970-01-01
      • 2014-03-16
      • 2016-03-15
      • 1970-01-01
      • 2021-09-24
      相关资源
      最近更新 更多