Skip to content

Fix classifier tags 1129#1140

Open
mariam851 wants to merge 4 commits intorasbt:masterfrom
mariam851:fix-classifier-tags-1129
Open

Fix classifier tags 1129#1140
mariam851 wants to merge 4 commits intorasbt:masterfrom
mariam851:fix-classifier-tags-1129

Conversation

@mariam851
Copy link
Contributor

@mariam851 mariam851 commented Dec 23, 2025

Hi @rasbt,

This PR addresses Issue #1129, where several mlxtend classifiers were incorrectly identified as regressors in newer versions of scikit-learn (1.6 and 1.7). This misclassification caused a ValueError when using scorers that rely on predict_proba (e.g., ROC AUC), as scikit-learn could not verify the estimator's type.

Changes Implemented
I have implemented the sklearn_tags method in the following estimators to ensure they are correctly recognized by the scikit-learn API:

Classifiers: MultiLayerPerceptron, EnsembleVoteClassifier, LogisticRegression, and SoftmaxRegression.

Regressors: StackingRegressor and StackingCVRegressor (added for consistent API support across the library).

For classification models, tags.estimator_type is explicitly set to "classifier".

Manual Verification
The fix was verified locally using scikit-learn 1.6+. The estimators are now correctly identified:

from mlxtend.classifier import MultiLayerPerceptron
clf = MultiLayerPerceptron()
tags = clf.sklearn_tags()
print(f"Recognized as classifier: {tags.estimator_type == 'classifier'}")

Output: True

Important Note on Environment & Formatting (Linting)
I tried to run black and isort locally to fix the linting issues, but I am encountering a known memory safety issue with Python 3.12.5 that prevents Black from running its AST safety checks. If the linting checks continue to fail in the CI, please let me know if you can run the formatter on your end, or I will attempt to fix it from a different environment.

Testing Notes
During local testing with pytest, I observed the following:

test_ensemble_vote_classifier.py: Some assertions failed due to numerical precision differences (e.g., 0.94 != 0.87). These failures are related to environment/version differences (Python 3.12 + latest scikit-learn) and are not caused by the changes in this PR.

check_estimator: Fails for LogisticRegression with a Labels not in {(0, 1)} error. This is an existing limitation of the model's binary design and is unrelated to the tagging implementation.

I followed a "Clean Update" strategy, ensuring only necessary compatibility tags were added without modifying existing logic.

Screenshot (23)

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

Successfully merging this pull request may close these issues.

2 participants