MAINT Use _check_sample_weight in GaussianNB
@@ -21,18 +21,17 @@ from abc import ABCMeta, abstractmethod
import numpy as np
-from scipy.sparse import issparse
from .base import BaseEstimator, ClassifierMixin
from .preprocessing import binarize
from .preprocessing import LabelBinarizer
from .preprocessing import label_binarize
-from .utils import check_X_y, check_array, check_consistent_length
+from .utils import check_X_y, check_array, deprecated
from .utils.extmath import safe_sparse_dot
from .utils.fixes import logsumexp
from .utils.multiclass import _check_partial_fit_first_call
from .utils.validation import check_is_fitted, check_non_negative, column_or_1d
-from .utils import deprecated
+from .utils.validation import _check_sample_weight
__all__ = ['BernoulliNB', 'GaussianNB', 'MultinomialNB', 'ComplementNB',
'CategoricalNB']
@@ -360,8 +359,7 @@ class GaussianNB(_BaseNB):
"""
X, y = check_X_y(X, y)
if sample_weight is not None:
- sample_weight = check_array(sample_weight, ensure_2d=False)
- check_consistent_length(y, sample_weight)
+ sample_weight = _check_sample_weight(sample_weight, X)
# If the ratio of data variance between dimensions is too small, it
# will cause numerical errors. To address this, we artificially
