Skip to content

Commit f28a90c

Browse files
ogriselqinhanmin2014
authored andcommitted
FIX restore BaseNB._check_X without abstractmethod decoration (#15997)
1 parent 70d8b70 commit f28a90c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

doc/whats_new/v0.22.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ Changelog
6161
:mod:`sklearn.naive_bayes`
6262
..........................
6363

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

6869
:mod:`sklearn.semi_supervised`
6970
..............................

sklearn/naive_bayes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ def _joint_log_likelihood(self, X):
5151
predict_proba and predict_log_proba.
5252
"""
5353

54+
def _check_X(self, X):
55+
"""To be overridden in subclasses with the actual checks."""
56+
# Note that this is not marked @abstractmethod as long as the
57+
# deprecated public alias sklearn.naive_bayes.BayesNB exists
58+
# (until 0.24) to preserve backward compat for 3rd party projects
59+
# with existing derived classes.
60+
return X
61+
5462
def predict(self, X):
5563
"""
5664
Perform classification on an array of test vectors X.

0 commit comments

Comments
 (0)