-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Passing categorical feature with data-type "Category" without passing "categorical_feature" #4460
Comments
@mohammad-saber Thanks for using LightGBM! 'category' columns in pandas.DataFrame are treated as categorical features by default in LightGBM. So,
you don't need to pass
Yes, it does.
Should be no difference with CASE 1. Maybe the following unit test will help to better understand handling categorical features in pandas.DataFrame.
Also, please note that ordered categorical columns ( LightGBM/tests/python_package_test/test_sklearn.py Lines 484 to 485 in d05f547
LightGBM/tests/python_package_test/test_sklearn.py Lines 515 to 516 in d05f547
|
Thank you. Is there any attribute that we can get "features which were treated as categorical" after model fitting? |
You can get this info from the LightGBM logs:
Also, categorical features are written differently in a model file. LightGBM/src/boosting/gbdt_model_text.cpp Lines 60 to 67 in 48257d4
|
This issue has been automatically closed because it has been awaiting a response for too long. When you have time to to work with the maintainers to resolve this issue, please post a new comment and it will be re-opened. If the issue has been locked for editing by the time you return to it, please open a new issue and reference this one. Thank you for taking the time to improve LightGBM! |
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. |
Thank you for sharing your great work. I have a question about handling categorical features without using ohe-hot enconding.
Assume that in the dataset, I have 2 categorical features.
I convert them into ordinal integer values and then convert data-type into "category".
Question:
When data-type is
"Category"
, do I need to pass parametercategorical_feature
when fitting model?CASE 1:
In the following case, does LightGBM handles columns
['B', 'C']
as categorical?CASE 2:
And what is the difference when I pass
categorical_feature
as below:Thank you for your time.
The text was updated successfully, but these errors were encountered: