scikit-learn-contrib / DESlib

A Python library for dynamic classifier and ensemble selection
BSD 3-Clause "New" or "Revised" License
477 stars 106 forks source link

Issue with using XGBClassifier #262

Open atifov opened 2 years ago

atifov commented 2 years ago

When I use XGBClassifier (from XGboost library) using any DES or DCS algorithm, I am getting a _featuresnames mismatch error. I have pooled several other classifiers successfully. This error only arises when Xgboost is included in the pooled classifiers. Moreover I have successfully been able to use XGBoost in the Deslib Stacked Classifier algorithm. Please note as per previous advice, I have installed the latest version (0.3.5) of the library using the code:

pip install git+https://github.com/scikit-learn-contrib/DESlib

Following is the main code:

X_train, X_test, Y_train, Y_test = train_test_split(X, y, test_size=0.2, random_state=0)

classifiers = [LogisticRegression(), RandomForestClassifier(), RUSBoostClassifier(), XGBClassifier(), DecisionTreeClassifier()]

for c in classifiers: c.fit(X_train, Y_train)

model = RRC(pool_classifiers=classifiers, random_state=0)

model.fit(X_train, Y_train)

ValueError: _featurenames mismatch:

Menelau commented 2 years ago

@atifov thanks for reporting this issue.

Apparently this happens due to a difference in implementation between sklearn ensembles and XGBoost. Let me dig deeper into this issue to come up with a solution to this compatibility problem.