diff --git a/doc/whats_new/v0.22.rst b/doc/whats_new/v0.22.rst index e36d7e925529d..394fd6ee8203c 100644 --- a/doc/whats_new/v0.22.rst +++ b/doc/whats_new/v0.22.rst @@ -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 `. +- |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 `. :mod:`sklearn.semi_supervised` .............................. diff --git a/sklearn/naive_bayes.py b/sklearn/naive_bayes.py index d958645b178f6..22bd339cbd6b0 100644 --- a/sklearn/naive_bayes.py +++ b/sklearn/naive_bayes.py @@ -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.