categorical data
Hi,
so far dummy coding categorical data worked fine. However, with the latest update, I see
Feature 3050 only contains one value, will be ignored
in the logs for each encoded column.
This only seems to be a problem when is_unbalance=true is passed
How should I handle categorical data for lightGBM so that it works fine?
Hi, @geoHeil , you had coverted categorical data to flatten 0/1 features, right? And I want to know which repo version is fine? Thanks
Current repo is fine if the parameter is set to false.
It was the first time I tried to set it to true.
Indeed 01 dummy coding was used. Guolin Ke [email protected] schrieb am Fr. 28. Okt. 2016 um 18:12:
Hi, @geoHeil https://github.com/geoHeil , you had coverted categorical data to flatten 0/1 features, right? And I want to know which repo version is fine? Thanks
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/LightGBM/issues/46#issuecomment-256962226, or mute the thread https://github.com/notifications/unsubscribe-auth/ABnc9GYFd2v56505AEKza2sPXUYkoduNks5q4h7PgaJpZM4Kjklr .
@geoHeil Got it, i will figure out why. Thanks
"is_unbalance=true" don't have any effect for feature extraction. So I have no idea what cause this. can you provide more details to me ? like the parameters you set, and a sample of data that can reproduce this.
I can hand you the paramters:
GBMClassifier(exec_path="/path/toLightGBM",
num_iterations=4000, learning_rate=0.01,
num_leaves=2000, min_data_in_leaf=100, metric='binary_logloss',
feature_fraction=0.7, bagging_fraction=0.7, bagging_freq=0,
metric_freq=1, early_stopping_round=20,
tree_learner="feature", num_threads=4,
is_unbalance=True)
If you cannot provide data.. can you provide more details about it? like #data, #num_category_of_that_feature, the distribution of these categories.. Or can you generate a fake data that re-produce this? One other suggestion is change "50000" to a bigger number in following lines: https://github.com/Microsoft/LightGBM/blob/master/src/io/dataset.cpp#L219 https://github.com/Microsoft/LightGBM/blob/master/src/io/dataset.cpp#L231 Then compile and try again.
Please find a jupyter notebook here https://github.com/geoHeil/pythonQuestions/blob/master/lightGBM.ipynb
Indeed, it will probably not be possible to share the data. Can you help me improve this minimal example?
This binary https://www.dropbox.com/s/k0wmfdk747km1pr/lightgbm?dl=0 compiled around lunch the day before yesterday works fine - even with unbalanced = True I think this is the hash 2af0dccd692d85fce1491c484c644bbf44d36f19
For me 3a06ce35ed3dfd882b246880f32866337f31ac99 seems to break something.
From that on I only receive
[LightGBM] [Fatal] [LightGBM] [Fatal] [LightGBM] [Fatal] [LightGBM] [Fatal] [LightGBM] [Fatal] [LightGBM] [Fatal] input format error, should be LibSVM[LightGBM] [Fatal] [LightGBM] [Fatal] input format error, should be LibSVMinput format error, should be LibSVMinput format error, should be LibSVMinput format error, should be LibSVMinput format error, should be LibSVM
input format error, should be LibSVMinput format error, should be LibSVM
@guolinke I found a reproducible example: https://github.com/ArdalanM/pyLightGBM/blob/master/notebooks/regression_example_kaggle_allstate.ipynb
errors with the LIBSVM error from above for the latest build -- with the old one it works fine.
@geoHeil I have try the https://github.com/ArdalanM/pyLightGBM/blob/master/notebooks/regression_example_kaggle_allstate.ipynb and it works fine... can you try to delete your local directory of LightGBM, and re-clone the latest one, then build a new binary? BTW, what is the OS you run with? windows or Ubuntu?
I can try that. Running on osx
edit
a fresh clone does not fix it. (last night) however, the svm format problem is fixed with the latest changes.
@geoHeil I fixed the bug for the prediction of libsvm. can you try again? BTW, can you work with categorical feature now?
As mentioned above: the SVM problem is fixed. Regarding the categorical data:
GBMClassifier(exec_path="path/lightgbm",
num_iterations=60, learning_rate=0.1,
num_leaves=2000, min_data_in_leaf=10, metric='binary_logloss',
feature_fraction=0.7, bagging_fraction=0.7, bagging_freq=0,
metric_freq=1, early_stopping_round=20,
tree_learner="serial", is_unbalance=True,
num_threads=4)
fails to predict a positive class if is_unbalance=True, however "works" / at least predicts more than 0 postivive class labels if this option is set to false. This seems to be strange for me.
The problem of:
[LightGBM] [Error] Feature Column_99 only contains one value, will be ignored
[LightGBM] [Error] Feature Column_111 only contains one value, will be ignored
[LightGBM] [Error] Feature Column_115 only contains one value, will be ignored
seems to persist.
@geoHeil
- can you give me some comparison of AUC/Logloss for is_unbalance=True and is_unbalance=False?
- Are all Column ignored when extracting features? or just some of them are ignored?
Regarding 1) I will need to rund some more comparison computations over the next couple of days. Regarding 2) only some columns are ignored.
What I can say so far: the serial learner results of no positive class labels being predicted (probably due to the warnings / errors above). In fact, the serial learner seems to stop after these errors and only the feature parallel learner continues below:
Feature Column_3130 only contains one value, will be ignored
[LightGBM] [Info] Finish loading data, use 5.299428 seconds
(Positive labels and negative labels are equalized via SMOTE)
[LightGBM] [Info] Number of postive:120298, number of negative:120298
[LightGBM] [Info] Number of data:240596, Number of features:2566
[LightGBM] [Info] Finish training initilization.
[LightGBM] [Info] Start train ...
[LightGBM] [Info] cannot find more split with gain = 0.000000 , current #leaves=921
The feature parallel learner on a single machine predicts more than 0 positive labels.
Shouldn't the outcome be more similar?
Anyway: regarding [LightGBM] [Error] Feature Column_21 only contains one value, will be ignored does lightgbm use 0 or 1 indexed data? would there be a way of obtaining the right label for such a column?
- you are using single machine, right? the result on serial_tree_learner should be same with feature_tree_learner. Are the serial_tree_learner really stop?
- some of columns are ignored have not much effect for the training. If one column is ignore, it means this column is very sparse. if you still want to use them, you can edit "50000" in https://github.com/Microsoft/LightGBM/blob/master/src/io/dataset.cpp#L219 to a bigger value(e.g. 500000). I will change this to the configurable parameter latter.
- can you update to the latest code? i fix one bug in un_balance training.
I will do the update. Do you believe that is_unbalance=True is better than an apriori SMOTE? Anyway: serial and feature seem to generate different results on my single machine.
hi @geoHeil , it's very difficult for us to reproduce this problem. could you shared some sampled data to us, especially Feature Column_21.
Please have a careful look at https://github.com/geoHeil/pythonQuestions/blob/master/lightGBM.ipynb I found a reproducible example