How to encode categorical features
I have a libsvm file containing a mix of continuous and categorical features, and I'm attempting to use LambdaRank on it. Here is a sample:
0.0 1:0.142095914742 7:1.0 302:1.0
0.0 1:0.20207253886 397:1.0 979:1.0
0.0 1:0.243902439024 68:1.0
1.0 1:0.142095914742 7:1.0 302:1.0
0.0 1:0.0689655172414 318:1.0 397:1.0
0.0 1:0.047619047619 45:1.0 323:1.0 531:1.0
When I train, I get the following:
[LightGBM] [Warning] Ignoring feature Column_33307, only has one value [LightGBM] [Warning] Ignoring feature Column_33308, only has one value [LightGBM] [Warning] Ignoring feature Column_33309, only has one value [LightGBM] [Warning] Ignoring feature Column_33310, only has one value [LightGBM] [Warning] Ignoring feature Column_33311, only has one value
I think this means it is ignoring my categorical features. How am I supposed to encode them?
its means that all of your sample have same value on these features, thus make these feature "unsplitable"
The maximum feature index I have is 4082
0.0 1:0.0926002480364 3:1.0 18:1.0 308:1.0 4082:1.0
My error log starts like this:
[LightGBM] [Info] Loading query boundaries...
[LightGBM] [Warning] Ignoring feature Column_0, only has one value
[LightGBM] [Warning] Ignoring feature Column_4, only has one value
[LightGBM] [Warning] Ignoring feature Column_12, only has one value
Where are the column names coming from? I don't have a feature index 0
@nlothian
- columns are ignored is because these columns only contain one value(like all zeros), or very sparse.
- What is the number of your data?
- The max index is really 4082 ? I see your log above are ignoring 30000+ features.
- The feature index in Libsvm start with
0, and you data don't use this column. so it will be ignored.
- I have 10,000 rows of data.
- Yes. This is one of the reasons I'm puzzled! I've attached my data and query file. Clearly I'm doing something wrong.
train.libsvm.zip train.libsvm.query.zip
.
Hi, @nlothian , I found feature index '33937' in your data file. you can check in line 1894.
Thanks @guolinke, my apologies - I missed it.
however, this warning doesn't affect the training result.
This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.