【问题标题】:did i use lgbm correctly for categorical features?我是否将 lgbm 正确用于分类特征?
【发布时间】:2020-02-20 00:20:43
【问题描述】:

假设我的数据只有 1 列分类特征(已经转换为 astype(int)),

x_to_use = x_to_use.astype(int)

我在 sklearn 管道中使用它:

                                LGBMRegressor(**{
                                            "n_estimators":100,
                                    "categorical_feature":(0,),
                                            "max_depth":1,
                                        }

我收到了这个警告。

c:\programdata\miniconda3\lib\site-packages\lightgbm\basic.py:842: UserWarning: categorical_feature keyword has been found in `params` an
Please use categorical_feature argument of the Dataset constructor to pass this parameter.

我希望所有内容都采用标准 sklearn 机器学习管道格式,因此我的输入始终是 np.array。我的管道构造是否正确或者是“categorical_feature”:(0,),只是被忽略并且该列不被视为分类。

编辑:

好的...我构造了一个简单的测试,“categorical_feature”实际上使用正确。

【问题讨论】:

  • ok...我构建了一个简单的测试,它确实可以正确处理“categorical_feature”。

标签: python scikit-learn lightgbm


【解决方案1】:

文档说:

-categorical_feature(字符串列表或int,或'auto',可选(默认='auto'))

您是否尝试过传递这样的列表?

LGBMRegressor(**{"n_estimators":100,
                 "categorical_feature":[0],
                 "max_depth":1}

【讨论】:

    猜你喜欢
    • 2012-02-07
    • 2021-04-04
    • 2017-04-09
    • 2020-07-27
    • 1970-01-01
    • 2019-08-09
    • 2021-10-23
    • 2013-03-14
    • 2020-08-15
    相关资源
    最近更新 更多