SynapseML icon indicating copy to clipboard operation
SynapseML copied to clipboard

Need to specify to native lightgbm learner if given columns are categorical

Open imatiach-msft opened this issue 8 years ago • 8 comments

Need to specify to native lightgbm learner if given columns are categorical Creating issue to track this based on conversation with @gopinutakki here

imatiach-msft avatar Aug 28 '18 19:08 imatiach-msft

When we assemble columns in spark we should propagate any columns that were indexed (via stringindexer or our valueindexer) to lightgbm native code

imatiach-msft avatar Aug 28 '18 19:08 imatiach-msft

updating based on conversation here -- it looks like it should be an easy fix, see here: https://github.com/Microsoft/LightGBM/blob/93764fda72ed3f7144455abd1e616f98be71c554/docs/Parameters.rst#categorical_feature and here: https://github.com/Microsoft/LightGBM/blob/93764fda72ed3f7144455abd1e616f98be71c554/docs/Advanced-Topics.rst#categorical-feature-support We just need to supply this parameter with the known categorical columns to lightgbm. We can expose this parameter to the user in case the user knows they are categorical and also we can automatically infer the columns that are categorical if they have been string indexed/value indexed based on the DataFrame metadata

imatiach-msft avatar Aug 28 '18 20:08 imatiach-msft

So the https://github.com/Azure/mmlspark/blob/master/src/lightgbm/src/main/scala/LightGBMUtils.scala do not encode the categorical features and I should transform the dataset before by myself?

friyal avatar Aug 29 '18 02:08 friyal

@friyal if you use the helper method featurizeData it will actually one-hot-encode the categoricals, but that is just a helper method. LightGBMClassifier/Regressor uses the Spark ML api so it can be compatible with all spark transforms (eg CrossValidator), which only takes in a vector of doubles for the features column.

This issue is more about enhancing how we handle categoricals that have been passed to LightGBM (eg index but don't one-hot-encode, and pass the list of categorical columns to the learner directly)

imatiach-msft avatar Aug 30 '18 22:08 imatiach-msft

Could you please expose this parameter so we can use the native LightGBM categorical features support? This is really important if we have categorical features with MANY levels and one-hot encoding is not feasible

ekerazha avatar Oct 04 '18 11:10 ekerazha

fix has been merged to master

imatiach-msft avatar Dec 11 '18 05:12 imatiach-msft

reopening as it looks like fix wasn't correct, the name/index passed to lightgbm should be for the slot and not for a column name, good thing this isn't released yet

imatiach-msft avatar Dec 26 '18 22:12 imatiach-msft

fixed again with new PR #463

imatiach-msft avatar Dec 28 '18 20:12 imatiach-msft