Skip to content

Refactor LinearBoostClassifier to remove sparse data support #12

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

Merged

Conversation

msamsami
Copy link
Contributor

@msamsami msamsami commented Jul 2, 2025

This PR refactors the LinearBoostClassifier to remove support for sparse data by creating a new intermediate base class (_DenseAdaBoostClassifier) that inherits from AdaBoostClassifier.

Problem:

The LinearBoostClassifier class is inherited from AdaBoostClassifier, which supports sparse matrices, but LinearBoostClassifier itself doesn't support sparse data due to using scalers such as MinMaxScaler, PowerTransformer, etc. This created inconsistency in the API documentation where inherited method docstrings suggested sparse matrix support when it wasn't actually available.

Solution:

  • Created _DenseAdaBoostClassifier base class that explicitly removes sparse data support
  • Updated docstrings for all inherited methods to specify dense array-only input
  • Override the _check_X method in _DenseAdaBoostClassifier and set accept_sparse=False
  • Configured sklearn tags to set tags.input_tags.sparse = False in _DenseAdaBoostClassifier for proper API declaration
  • Modified LinearBoostClassifier to inherit from the new base class

Changes:

  • Enhanced API consistency and clarity
  • Prevents user confusion about supported input types
  • Maintains full functionality while providing accurate documentation

@hamidkm9 hamidkm9 merged commit 2275f4b into LinearBoost:main Jul 3, 2025
6 checks passed
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