8000 Doc numpydoc validation for docstrings in BernoulliNB by LauraLangdon · Pull Request #15513 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Doc numpydoc validation for docstrings in BernoulliNB #15513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions sklearn/naive_bayes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -943,22 +943,13 @@ 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 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the backslash at the end is not needed.

Copy link
Contributor Author
@LauraLangdon LauraLangdon Nov 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @rth! I tried having that bit of text on one line, but the pytest failed. Splitting into two lines made the pytest succeed, but when I submitted the PR without the backslash at the end, the lint check failed. Adding it at the recommendation of @TomDLT made it pass the lint test.

Is there another approach I should try instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, the docstring renders fine in any case. Thanks!

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
Expand All @@ -969,6 +960,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,
3B55 Expand Down
0