Lightgbm: 'categorical_feature in param dict is overridden.'

Created on 31 May 2018  ·  6Comments  ·  Source: microsoft/LightGBM

Why this warning?lgb.Dataset params is None.
Thank you.

Environment info

Operating System、CPU:Linux Server
C++/Python/R version:Python lightgbm 2.1.1

Error Message:

warnings.warn('categorical_feature in param dict is overridden.')

Reproducible examples

   def train(self, train_feature, train_label):
    train = self.__lgb.Dataset(
        data=train_feature,
        label=train_label,
        feature_name=train_feature.columns.tolist(),
        categorical_feature=self.__categorical_feature.tolist()
    )
    self.__clf = self.__lgb.train(
        self.__train_params,
        train,
        num_boost_round=self.__num_boost_round,
        categorical_feature=self.__categorical_feature.tolist()
    )

Most helpful comment

@StrikerRUS Warning still exsits.
pic

All 6 comments

@JYLFamily This warning is raised because you're passing categorical features twice: when constuct Dataset and when call train.

The correct way is to pass them only while constructing Dataset via categorical_feature argument.

This warning appears also when the categorical features are only passed to train and not specified anywhere else.

The correct way is to pass them only while constructing Dataset via categorical_feature argument.

import lightgbm as lgb

from sklearn.datasets import load_boston

X, y = load_boston(True)
lgb_data = lgb.Dataset(X, y, categorical_feature=[1, 2])
lgb.train({}, lgb_data)
D:\Miniconda3\lib\site-packages\lightgbm\basic.py:1247: UserWarning: Using categorical_feature in Dataset.
  warnings.warn('Using categorical_feature in Dataset.')

This warning is expected as per #792.

@StrikerRUS
maybe we can discard that warning when the data source is not pandas? I think the auto mode only works for pandas.

@guolinke

I think the auto mode only works for pandas.

Yeah, I think so.

maybe we can discard that warning when the data source is not pandas?

OK, I'll take a look.

@StrikerRUS Warning still exsits.
pic

Was this page helpful?
0 / 5 - 0 ratings