LightGBM does not accept the dtypes of my data

Tags: , , ,



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?

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.



Source: stackoverflow