Skip to content

DOC ensure Naive Bayes classes passes numpydoc validation #20440

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 67 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
1a7f2fb
Update default doc string values
genvalen Jun 6, 2020
ca94a79
Update default docstrings for Metrics
genvalen Jun 7, 2020
cc09f9d
Fix lint error
genvalen Jun 7, 2020
a899bef
Merge remote-tracking branch 'upstream/master' into linear-model-defa…
genvalen Jun 7, 2020
c8cd424
Resolve merge conflicts
genvalen Jun 7, 2020
da935ac
Fix flake8 error
genvalen Jun 7, 2020
bede6d0
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
7b4647e
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
cfe8b2b
Update sklearn/metrics/_base.py
genvalen Jun 9, 2020
1ec16e8
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
5e52205
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
8df195e
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
c93effd
Update sklearn/metrics/pairwise.py
genvalen Jun 9, 2020
57ca202
Update sklearn/metrics/pairwise.py
genvalen Jun 9, 2020
3937592
Update sklearn/metrics/pairwise.py
genvalen Jun 9, 2020
a069d00
Update sklearn/metrics/pairwise.py
genvalen Jun 9, 2020
a82ee38
Update sklearn/metrics/pairwise.py
genvalen Jun 9, 2020
572ca85
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
89af371
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
601c757
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
4ed3830
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
1fa4425
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
48a5908
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
881f733
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
c85c836
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
9286fcb
Update sklearn/metrics/_classification.py
genvalen Jun 9, 2020
8367323
Update sklearn/metrics/_ranking.py
genvalen Jun 9, 2020
056c8e9
Update sklearn/metrics/_classification.py
genvalen Jun 10, 2020
036b8b6
Update sklearn/metrics/_classification.py
genvalen Jun 10, 2020
1a83796
Update sklearn/metrics/_classification.py
genvalen Jun 10, 2020
a3d0e1a
Update sklearn/metrics/_ranking.py
genvalen Jun 10, 2020
8573644
Update sklearn/metrics/_ranking.py
genvalen Jun 11, 2020
c291010
Update sklearn/metrics/_ranking.py
genvalen Jun 11, 2020
40dc8b0
Update sklearn/metrics/_ranking.py
genvalen Jun 12, 2020
769e6fb
Update sklearn/metrics/_ranking.py
genvalen Jun 12, 2020
0848721
Update sklearn/metrics/_regression.py
genvalen Jun 12, 2020
37963a2
Apply suggestions from code review
genvalen Jun 12, 2020
dc5cc39
Make edits
genvalen Jun 12, 2020
711658b
Make edits
genvalen Jun 12, 2020
808e240
Fix merge conflicts
genvalen Jun 11, 2021
0da8b25
Fix another merge conflict
genvalen Jun 11, 2021
abeeb66
Merge branch 'main' of https://github.com/scikit-learn/scikit-learn i…
genvalen Jun 12, 2021
12082a8
Merge remote-tracking branch 'upstream/main' into main
genvalen Jun 20, 2021
f592334
Merge branch 'main' of https://github.com/scikit-learn/scikit-learn i…
genvalen Jun 26, 2021
c826dc9
Merge branch 'main' of https://github.com/scikit-learn/scikit-learn i…
genvalen Jun 29, 2021
1f701ee
Merge branch 'main' of https://github.com/scikit-learn/scikit-learn i…
genvalen Jun 29, 2021
20ab7df
Merge branch 'main' of https://github.com/scikit-learn/scikit-learn i…
genvalen Jun 30, 2021
0c63c29
Merge branch 'main' of https://github.com/scikit-learn/scikit-learn i…
genvalen Jul 2, 2021
0fa9b85
Accept incoming change from previous merge
genvalen Jul 2, 2021
b1da24a
Update all Naive Bayes classes with a 'see also' section.
genvalen Jul 2, 2021
716e63a
Remove trailing spaces
genvalen Jul 2, 2021
c8c6886
Merge branch 'main' of https://github.com/scikit-learn/scikit-learn i…
genvalen Jul 5, 2021
97f16c1
Merge branch 'main' of https://github.com/scikit-learn/scikit-learn i…
genvalen Jul 6, 2021
94330a8
Merge branch 'main' of https://github.com/scikit-learn/scikit-learn i…
genvalen Jul 6, 2021
f94b317
Merge branch 'main' into update_NB_classes
genvalen Jul 6, 2021
05e263b
Remove remaining Naiive Bayes classes from DOCSTRING_IGNORE_LIST.
genvalen Jul 6, 2021
9b54e0f
Ensure GaussianNB passes numpydoc validation
genvalen Jul 6, 2021
d7ea7d0
Ensure MultinominalNB passes numpydoc validation
genvalen Jul 6, 2021
422bdfe
Ensure ComplementNB passes numpydoc validation
genvalen Jul 6, 2021
5d5741d
Update sklearn/naive_bayes.py
genvalen Jul 7, 2021
7833ee7
Update sklearn/naive_bayes.py
genvalen Jul 7, 2021
991157d
Update sklearn/naive_bayes.py
genvalen Jul 7, 2021
91747ba
Update sklearn/naive_bayes.py
genvalen Jul 7, 2021
3fdaf50
Merge branch 'main' into update_NB_classes
genvalen Jul 10, 2021
dcd4423
Merge branch 'main' of https://github.com/genvalen/scikit-learn into …
genvalen Jul 10, 2021
324da0e
Merge branch 'main' into update_NB_classes
genvalen Jul 10, 2021
85a5622
Merge branch 'update_NB_classes' of https://github.com/genvalen/sciki…
genvalen Jul 10, 2021
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
3 changes: 0 additions & 3 deletions maint_tools/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"CalibratedClassifierCV",
"ClassifierChain",
"ColumnTransformer",
"ComplementNB",
"CountVectorizer",
"DecisionTreeRegressor",
"DictVectorizer",
Expand All @@ -40,7 +39,6 @@
"FunctionTransformer",
"GammaRegressor",
"GaussianMixture",
"GaussianNB",
"GaussianProcessRegressor",
"GaussianRandomProjection",
"GenericUnivariateSelect",
Expand Down Expand Up @@ -90,7 +88,6 @@
"MultiTaskElasticNetCV",
"MultiTaskLasso",
"MultiTaskLassoCV",
"MultinomialNB",
"NMF",
"NearestCentroid",
"NeighborhoodComponentsAnalysis",
Expand Down
64 changes: 44 additions & 20 deletions sklearn/naive_bayes.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def predict_proba(self, X):

class GaussianNB(_BaseNB):
"""
Gaussian Naive Bayes (GaussianNB)
Gaussian Naive Bayes (GaussianNB).

Can perform online updates to model parameters via :meth:`partial_fit`.
For details on algorithm used to update feature means and variance online,
Expand Down Expand Up @@ -183,6 +183,13 @@ class labels known to the classifier.
theta_ : ndarray of shape (n_classes, n_features)
mean of each feature per class.

See Also
--------
BernoulliNB : Naive Bayes classifier for multivariate Bernoulli models.
CategoricalNB : Naive Bayes classifier for categorical features.
ComplementNB : Complement Naive Bayes classifier.
MultinomialNB : Naive Bayes classifier for multinomial models.

Examples
--------
>>> import numpy as np
Expand Down Expand Up @@ -226,6 +233,7 @@ def fit(self, X, y, sample_weight=None):
Returns
-------
self : object
Returns the instance itself.
"""
X, y = self._validate_data(X, y)
return self._partial_fit(
Expand Down Expand Up @@ -346,6 +354,7 @@ def partial_fit(self, X, y, classes=None, sample_weight=None):
Returns
-------
self : object
Returns the instance itself.
"""
return self._partial_fit(
X, y, classes, _refit=False, sample_weight=sample_weight
Expand Down Expand Up @@ -724,7 +733,7 @@ def n_features_(self):

class MultinomialNB(_BaseDiscreteNB):
"""
Naive Bayes classifier for multinomial models
Naive Bayes classifier for multinomial models.

The multinomial Naive Bayes classifier is suitable for classification with
discrete features (e.g., word counts for text classification). The
Expand Down Expand Up @@ -796,18 +805,12 @@ class MultinomialNB(_BaseDiscreteNB):

.. versionadded:: 0.24

Examples
See Also
--------
>>> import numpy as np
>>> rng = np.random.RandomState(1)
>>> X = rng.randint(5, size=(6, 100))
>>> y = np.array([1, 2, 3, 4, 5, 6])
>>> from sklearn.naive_bayes import MultinomialNB
>>> clf = MultinomialNB()
>>> clf.fit(X, y)
MultinomialNB()
>>> print(clf.predict(X[2:3]))
[3]
BernoulliNB : Naive Bayes classifier for multivariate Bernoulli models.
CategoricalNB : Naive Bayes classifier for categorical features.
ComplementNB : Complement Naive Bayes classifier.
GaussianNB : Gaussian Naive Bayes.

Notes
-----
Expand All @@ -820,6 +823,19 @@ class MultinomialNB(_BaseDiscreteNB):
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/naive-bayes-text-classification-1.html

Examples
--------
>>> import numpy as np
>>> rng = np.random.RandomState(1)
>>> X = rng.randint(5, size=(6, 100))
>>> y = np.array([1, 2, 3, 4, 5, 6])
>>> from sklearn.naive_bayes import MultinomialNB
>>> clf = MultinomialNB()
>>> clf.fit(X, y)
MultinomialNB()
>>> print(clf.predict(X[2:3]))
[3]
"""

def __init__(self, *, alpha=1.0, fit_prior=True, class_prior=None):
Expand Down Expand Up @@ -930,6 +946,20 @@ class ComplementNB(_BaseDiscreteNB):

.. versionadded:: 0.24

See Also
--------
BernoulliNB : Naive Bayes classifier for multivariate Bernoulli models.
CategoricalNB : Naive Bayes classifier for categorical features.
GaussianNB : Gaussian Naive Bayes.
MultinomialNB : Naive Bayes classifier for multinomial models.

References
----------
Rennie, J. D., Shih, L., Teevan, J., & Karger, D. R. (2003).
Tackling the poor assumptions of naive bayes text classifiers. In ICML
(Vol. 3, pp. 616-623).
https://people.csail.mit.edu/jrennie/papers/icml03-nb.pdf

Examples
--------
>>> import numpy as np
Expand All @@ -942,13 +972,6 @@ class ComplementNB(_BaseDiscreteNB):
ComplementNB()
>>> print(clf.predict(X[2:3]))
[3]

References
----------
Rennie, J. D., Shih, L., Teevan, J., & Karger, D. R. (2003).
Tackling the poor assumptions of naive bayes text classifiers. In ICML
(Vol. 3, pp. 616-623).
https://people.csail.mit.edu/jrennie/papers/icml03-nb.pdf
"""

def __init__(self, *, alpha=1.0, fit_prior=True, class_prior=None, norm=False):
Expand Down Expand Up @@ -1218,6 +1241,7 @@ class CategoricalNB(_BaseDiscreteNB):

See Also
--------
BernoulliNB : Naive Bayes classifier for multivariate Bernoulli models.
ComplementNB : Complement Naive Bayes classifier.
GaussianNB : Gaussian Naive Bayes.
MultinomialNB : Naive Bayes classifier for multinomial models.
Expand Down