Skip to content

Commit 75e9bc0

Browse files
LauraLangdonrth
authored andcommitted
Doc numpydoc validation for docstrings in BernoulliNB (#15513)
1 parent d3c7387 commit 75e9bc0

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

sklearn/naive_bayes.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ class BernoulliNB(_BaseDiscreteNB):
908908
Threshold for binarizing (mapping to booleans) of sample features.
909909
If None, input is presumed to already consist of binary vectors.
910910
911-
fit_prior : boolean, optional (default=True)
911+
fit_prior : bool, optional (default=True)
912912
Whether to learn class prior probabilities or not.
913913
If false, a uniform prior will be used.
914914
@@ -942,22 +942,13 @@ class BernoulliNB(_BaseDiscreteNB):
942942
classes_ : array of shape (n_classes,)
943943
The classes labels.
944944
945-
Examples
946-
--------
947-
>>> import numpy as np
948-
>>> rng = np.random.RandomState(1)
949-
>>> X = rng.randint(5, size=(6, 100))
950-
>>> Y = np.array([1, 2, 3, 4, 4, 5])
951-
>>> from sklearn.naive_bayes import BernoulliNB
952-
>>> clf = BernoulliNB()
953-
>>> clf.fit(X, Y)
954-
BernoulliNB()
955-
>>> print(clf.predict(X[2:3]))
956-
[3]
945+
See Also
946+
----------
947+
MultinomialNB: The multinomial Naive Bayes classifier is \
948+
suitable for classification with discrete features.
957949
958950
References
959951
----------
960-
961952
C.D. Manning, P. Raghavan and H. Schuetze (2008). Introduction to
962953
Information Retrieval. Cambridge University Press, pp. 234-265.
963954
https://nlp.stanford.edu/IR-book/html/htmledition/the-bernoulli-model-1.html
@@ -968,6 +959,19 @@ class BernoulliNB(_BaseDiscreteNB):
968959
969960
V. Metsis, I. Androutsopoulos and G. Paliouras (2006). Spam filtering with
970961
naive Bayes -- Which naive Bayes? 3rd Conf. on Email and Anti-Spam (CEAS).
962+
963+
Examples
964+
--------
965+
>>> import numpy as np
966+
>>> rng = np.random.RandomState(1)
967+
>>> X = rng.randint(5, size=(6, 100))
968+
>>> Y = np.array([1, 2, 3, 4, 4, 5])
969+
>>> from sklearn.naive_bayes import BernoulliNB
970+
>>> clf = BernoulliNB()
971+
>>> clf.fit(X, Y)
972+
BernoulliNB()
973+
>>> print(clf.predict(X[2:3]))
974+
[3]
971975
"""
972976

973977
def __init__(self, alpha=1.0, binarize=.0, fit_prior=True,

0 commit comments

Comments
 (0)