From 3a83dcfeabb4f194a96d614f9944118c4a7ac413 Mon Sep 17 00:00:00 2001 From: g0g0gadget <48335772+g0g0gadget@users.noreply.github.com> Date: Sat, 2 Nov 2019 15:17:35 -0700 Subject: [PATCH 1/2] Doc fix --- sklearn/naive_bayes.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/sklearn/naive_bayes.py b/sklearn/naive_bayes.py index be9450d7334f0..c37095c5f7051 100644 --- a/sklearn/naive_bayes.py +++ b/sklearn/naive_bayes.py @@ -909,7 +909,7 @@ class BernoulliNB(BaseDiscreteNB): Threshold for binarizing (mapping to booleans) of sample features. If None, input is presumed to already consist of binary vectors. - fit_prior : boolean, optional (default=True) + fit_prior : bool, optional (default=True) Whether to learn class prior probabilities or not. If false, a uniform prior will be used. @@ -943,22 +943,12 @@ class BernoulliNB(BaseDiscreteNB): classes_ : array of shape (n_classes,) The classes labels. - Examples - -------- - >>> import numpy as np - >>> rng = np.random.RandomState(1) - >>> X = rng.randint(5, size=(6, 100)) - >>> Y = np.array([1, 2, 3, 4, 4, 5]) - >>> from sklearn.naive_bayes import BernoulliNB - >>> clf = BernoulliNB() - >>> clf.fit(X, Y) - BernoulliNB() - >>> print(clf.predict(X[2:3])) - [3] + See Also + ---------- + MultinomialNB: The multinomial Naive Bayes classifier is suitable for classification with discrete features. References ---------- - C.D. Manning, P. Raghavan and H. Schuetze (2008). Introduction to Information Retrieval. Cambridge University Press, pp. 234-265. https://nlp.stanford.edu/IR-book/html/htmledition/the-bernoulli-model-1.html @@ -969,6 +959,19 @@ class BernoulliNB(BaseDiscreteNB): V. Metsis, I. Androutsopoulos and G. Paliouras (2006). Spam filtering with naive Bayes -- Which naive Bayes? 3rd Conf. on Email and Anti-Spam (CEAS). + + Examples + -------- + >>> import numpy as np + >>> rng = np.random.RandomState(1) + >>> X = rng.randint(5, size=(6, 100)) + >>> Y = np.array([1, 2, 3, 4, 4, 5]) + >>> from sklearn.naive_bayes import BernoulliNB + >>> clf = BernoulliNB() + >>> clf.fit(X, Y) + BernoulliNB() + >>> print(clf.predict(X[2:3])) + [3] """ def __init__(self, alpha=1.0, binarize=.0, fit_prior=True, From 592d337846f79a53b5306c4552e08c2f7537bb07 Mon Sep 17 00:00:00 2001 From: g0g0gadget <48335772+g0g0gadget@users.noreply.github.com> Date: Sat, 2 Nov 2019 16:30:48 -0700 Subject: [PATCH 2/2] New doc fix --- sklearn/naive_bayes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sklearn/naive_bayes.py b/sklearn/naive_bayes.py index c37095c5f7051..0b7cbc2eaeb33 100644 --- a/sklearn/naive_bayes.py +++ b/sklearn/naive_bayes.py @@ -945,7 +945,8 @@ class BernoulliNB(BaseDiscreteNB): See Also ---------- - MultinomialNB: The multinomial Naive Bayes classifier is suitable for classification with discrete features. + MultinomialNB: The multinomial Naive Bayes classifier is \ + suitable for classification with discrete features. References ----------