Skip to content
Advertisement

LightGBM does not accept the dtypes of my data

I’m trying to use LGBMClassifier and for some reason, he does not accept the types of my data (all features are not accepted, I tested it).

When we look at my data we can clearly see that all dtypes are either category, float or int (pd.DataFrame.info())

dtypes: category(275), float64(115), int64(9)

When I eventually try to train my LGBMClassifier I get the follwoing Error:

ValueError: Series.dtypes must be int, float or bool

Has anyone an idea what is wrong?

Advertisement

Answer

I figured out that the error:

ValueError: Series.dtypes must be int, float or bool

refers in my case to the label, thus to the only passed series to the lgb.train() method. My label had the type category which can not be handled by lgb.train(). I had to change the dtype from ‘category’ to ‘int’. Then It worked.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement