Autogluon: LightGBM error special JSON characters in feature name

Created on 1 Apr 2020  路  10Comments  路  Source: awslabs/autogluon

Hi - great library everyone!

I'm doing tabular prediction with news article data. The LightGBM model doesn't run with the following error:

LightGBMError: Do not support special JSON characters in feature name.
Do not support special JSON characters in feature name.

The upstream issue in LightGBM is here:https://github.com/microsoft/LightGBM/issues/2455

Basically they check for special json characters .e.g [],{}": in features names and throw an error if found. Could autogluon check for these characters and remove any offending features?

Liam

bug tabular

Most helpful comment

Thanks for the info @oguzhangur96! Right now the main difficulty here is to ensure that column names are always converted when entering the model (whether for feature importances, fit, inference) and also inversely converted back to the original upon leaving. This seems to be something that LightGBM itself should handle, and I don't have a good understanding of why they haven't done so.

Furthermore, it isn't sufficient to only remove the special characters, because we have to ensure no two columns have the same name. One simple way is to just rename columns 0-n as '0', '1', ...'n-1', 'n', but then this operation would also have to be done on all of the 99% of problems where this is not required, particularly for online-inference of single rows. I have to first benchmark inference times in these situations to ensure our online-inference speed isn't significantly slowed due to this fix.

All 10 comments

Good catch, thanks for the info! Just to clarify, LightGBM fails in this scenario, but the rest of the models train successfully and you are able to get a result from AutoGluon?

If so, I think I can look into fixing this, the question is if I can get it to still use the features rather than dropping them entirely (I think I can by clever renaming).

Yep, everything else works fine and I get a result at the end

To aid in testing to ensure I am covering all of the failure cases, could you provide a sample training data of the news article data you are experiencing the problem with or the location which you obtained the data? If you wish to keep it private that is fine, but it could help accelerating the fix on my end.

Sure - first 3 rows of csv are enough to trigger it - see attached zip.
err.tar.gz

Is there a way to access errors in the underlying models using the %debug in ipython?

Hi,

I have encountred the same problem. Fixed it before the training begins with a regular expression and lambda function (pandas). Object named "_data_" must be a dataframe.

import re
data = data.rename(columns = lambda x:re.sub('[^A-Za-z0-9_]+', '', x))

Could provide data/column headers if needed.

Thanks for the info @oguzhangur96! Right now the main difficulty here is to ensure that column names are always converted when entering the model (whether for feature importances, fit, inference) and also inversely converted back to the original upon leaving. This seems to be something that LightGBM itself should handle, and I don't have a good understanding of why they haven't done so.

Furthermore, it isn't sufficient to only remove the special characters, because we have to ensure no two columns have the same name. One simple way is to just rename columns 0-n as '0', '1', ...'n-1', 'n', but then this operation would also have to be done on all of the 99% of problems where this is not required, particularly for online-inference of single rows. I have to first benchmark inference times in these situations to ensure our online-inference speed isn't significantly slowed due to this fix.

@braaannigan , @oguzhangur96

451 is merged and should fix this issue (Just in time for our upcoming 0.0.7 release!). I have tested this on various NLP problems which previously caused crashes, and it successfully trains.

Thanks again for highlighting this issue!

Best,
Nick

Great - looking forward to the next release!

how can i fix this error "LightGBMError: Do not support special JSON characters in feature name."

@ind-kum Please check your AutoGluon version and upgrade to 0.0.10 if you haven't. This should fix the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jwmueller picture jwmueller  路  6Comments

nathan-wood picture nathan-wood  路  5Comments

elife33 picture elife33  路  5Comments

rebotnix picture rebotnix  路  3Comments

tigerhawkvok picture tigerhawkvok  路  6Comments