@@ -71,11 +71,12 @@ def predict(self, X):
71
71
Parameters
72
72
----------
73
73
X : array-like of shape (n_samples, n_features)
74
+ The input samples.
74
75
75
76
Returns
76
77
-------
77
78
C : ndarray of shape (n_samples,)
78
- Predicted target values for X
79
+ Predicted target values for X.
79
80
"""
80
81
check_is_fitted (self )
81
82
X = self ._check_X (X )
@@ -89,6 +90,7 @@ def predict_log_proba(self, X):
89
90
Parameters
90
91
----------
91
92
X : array-like of shape (n_samples, n_features)
93
+ The input samples.
92
94
93
95
Returns
94
96
-------
@@ -111,6 +113,7 @@ def predict_proba(self, X):
111
113
Parameters
112
114
----------
113
115
X : array-like of shape (n_samples, n_features)
116
+ The input samples.
114
117
115
118
Returns
116
119
-------
@@ -203,7 +206,7 @@ def __init__(self, *, priors=None, var_smoothing=1e-9):
203
206
self .var_smoothing = var_smoothing
204
207
205
208
def fit (self , X , y , sample_weight = None ):
206
- """Fit Gaussian Naive Bayes according to X, y
209
+ """Fit Gaussian Naive Bayes according to X, y.
207
210
208
211
Parameters
209
212
----------
@@ -576,6 +579,7 @@ def partial_fit(self, X, y, classes=None, sample_weight=None):
576
579
Returns
577
580
-------
578
581
self : object
582
+ Returns the instance itself.
579
583
"""
580
584
first_call = not hasattr (self , "classes_" )
581
585
X , y = self ._check_X_y (X , y , reset = first_call )
@@ -622,7 +626,7 @@ def partial_fit(self, X, y, classes=None, sample_weight=None):
622
626
return self
623
627
624
628
def fit (self , X , y , sample_weight = None ):
625
- """Fit Naive Bayes classifier according to X, y
629
+ """Fit Naive Bayes classifier according to X, y.
626
630
627
631
Parameters
628
632
----------
@@ -639,6 +643,7 @@ def fit(self, X, y, sample_weight=None):
639
643
Returns
640
644
-------
641
645
self : object
646
+ Returns the instance itself.
642
647
"""
643
648
X , y = self ._check_X_y (X , y )
644
649
_ , n_features = X .shape
@@ -1049,18 +1054,13 @@ class BernoulliNB(_BaseDiscreteNB):
1049
1054
1050
1055
.. versionadded:: 0.24
1051
1056
1052
- Examples
1057
+ See Also
1053
1058
--------
1054
- >>> import numpy as np
1055
- >>> rng = np.random.RandomState(1)
1056
- >>> X = rng.randint(5, size=(6, 100))
1057
- >>> Y = np.array([1, 2, 3, 4, 4, 5])
1058
- >>> from sklearn.naive_bayes import BernoulliNB
1059
- >>> clf = BernoulliNB()
1060
- >>> clf.fit(X, Y)
1061
- BernoulliNB()
1062
- >>> print(clf.predict(X[2:3]))
1063
- [3]
1059
+ CategoricalNB : Naive Bayes classifier for categorical features.
1060
+ ComplementNB : The Complement Naive Bayes classifier
1061
+ described in Rennie et al. (2003).
1062
+ GaussianNB : Gaussian Naive Bayes (GaussianNB).
1063
+ MultinomialNB : Naive Bayes classifier for multinomial models.
1064
1064
1065
1065
References
1066
1066
----------
@@ -1074,6 +1074,19 @@ class BernoulliNB(_BaseDiscreteNB):
1074
1074
1075
1075
V. Metsis, I. Androutsopoulos and G. Paliouras (2006). Spam filtering with
1076
1076
naive Bayes -- Which naive Bayes? 3rd Conf. on Email and Anti-Spam (CEAS).
1077
+
1078
+ Examples
1079
+ --------
1080
+ >>> import numpy as np
1081
+ >>> rng = np.random.RandomState(1)
1082
+ >>> X = rng.randint(5, size=(6, 100))
1083
+ >>> Y = np.array([1, 2, 3, 4, 4, 5])
1084
+ >>> from sklearn.naive_bayes import BernoulliNB
1085
+ >>> clf = BernoulliNB()
1086
+ >>> clf.fit(X, Y)
1087
+ BernoulliNB()
1088
+ >>> print(clf.predict(X[2:3]))
1089
+ [3]
1077
1090
"""
1078
1091
1079
1092
def __init__ (self , * , alpha = 1.0 , binarize = 0.0 , fit_prior = True , class_prior = None ):
@@ -1226,7 +1239,7 @@ def __init__(
1226
1239
self .min_categories = min_categories
1227
1240
1228
1241
def fit (self , X , y , sample_weight = None ):
1229
- """Fit Naive Bayes classifier according to X, y
1242
+ """Fit Naive Bayes classifier according to X, y.
1230
1243
1231
1244
Parameters
1232
1245
----------
@@ -1248,6 +1261,7 @@ def fit(self, X, y, sample_weight=None):
1248
1261
Returns
1249
1262
-------
1250
1263
self : object
1264
+ Returns the instance itself.
1251
1265
"""
1252
1266
return super ().fit (X , y , sample_weight = sample_weight )
1253
1267
@@ -1291,6 +1305,7 @@ def partial_fit(self, X, y, classes=None, sample_weight=None):
1291
1305
Returns
1292
1306
-------
1293
1307
self : object
1308
+ Returns the instance itself.
1294
1309
"""
1295
1310
return super ().partial_fit (X , y , classes , sample_weight = sample_weight )
1296
1311
0 commit comments