Skip to content

Fix restore BaseNB._check_X without abstractmethod decoration #15997

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
merged 3 commits into from
Jan 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions doc/whats_new/v0.22.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ Changelog
:mod:`sklearn.naive_bayes`
..........................

- |Fix| removed abstract method `_check_X` from :class:`naive_bayes.BaseNB`
that could break downstream projects inheriting from this deprecated
public base class. :pr:`15996` by :user:`Brigitta Sipőcz <bsipocz>`.
- |Fix| Removed `abstractmethod` decorator for the method `_check_X` in
:class:`naive_bayes.BaseNB` that could break downstream projects inheriting
from this deprecated public base class. :pr:`15996` by
:user:`Brigitta Sipőcz <bsipocz>`.

:mod:`sklearn.semi_supervised`
..............................
Expand Down
8 changes: 8 additions & 0 deletions sklearn/naive_bayes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def _joint_log_likelihood(self, X):
predict_proba and predict_log_proba.
"""

def _check_X(self, X):
"""To be overridden in subclasses with the actual checks."""
# Note that this is not marked @abstractmethod as long as the
# deprecated public alias sklearn.naive_bayes.BayesNB exists
# (until 0.24) to preserve backward compat for 3rd party projects
# with existing derived classes.
return X

def predict(self, X):
"""
Perform classification on an array of test vectors X.
Expand Down