Skip to content
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

ENH : Option to explicitly mention categorical columns during fit #127

Open
lashdk opened this issue Jan 27, 2024 · 0 comments
Open

ENH : Option to explicitly mention categorical columns during fit #127

lashdk opened this issue Jan 27, 2024 · 0 comments

Comments

@lashdk
Copy link

lashdk commented Jan 27, 2024

Description of Enhancement :
BaseModel during self._fetch_meta() selects categorical based on if the column dtype is 'object'. This is typically acceptable and would cover 95% of use cases but the inbuilt pandas dtype categorical would be missed by this . I propose we add categorical_feature parameter to our fit methods like in LGBM's fit method : categorical_feature (list of str or int, or 'auto', optional (default='auto'))(https://lightgbm.readthedocs.io/en/latest/pythonapi/lightgbm.LGBMClassifier.html#lightgbm.LGBMClassifier.fit)

How to reproduce:

from xplainable.core.models import XClassifier
from sklearn.datasets import make_classification
import numpy as np
X, y = make_classification(n_samples=1000,n_features=4,random_state=42,n_classes=2)
X = pd.DataFrame(X,columns=['Feat_'+str(i) for i in range(4)])
y = pd.Series(y)
X['Feat_0'] = X['Feat_0'].astype('category')
print(list(X.select_dtypes('object')))

Screenshot
image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant