Fixed comments

This commit is contained in:
ricca 2023-10-03 20:18:09 +02:00
parent c375df23fd
commit 9fa8164458

View File

@ -1,8 +1,10 @@
""" """
Implementation from scratch of a Multinomial Naive Bayes Classifier. Implementation from scratch of a Multinomial Naive Bayes Classifier.
The algorithm is trained and tested on the twenty_newsgroup dataset from sklearn to perform text classification The algorithm is trained and tested on the twenty_newsgroup dataset
from sklearn to perform text classification
Here the Wikipedia page to understand the theory behind this kind of probabilistic models: Here the Wikipedia page to understand the theory behind this kind
of probabilistic models:
https://en.wikipedia.org/wiki/Naive_Bayes_classifier https://en.wikipedia.org/wiki/Naive_Bayes_classifier
""" """
@ -28,7 +30,8 @@ def group_indices_by_target(targets: ArrayLike) -> dict:
Returns Returns
---------- ----------
grouped_indices : dict of (label : list) grouped_indices : dict of (label : list)
Maps each target label to the list of indices of the examples with that label Maps each target label to the list of indices of the
examples with that label
Example Example
---------- ----------
@ -90,8 +93,8 @@ class MultinomialNBClassifier:
Example Example
---------- ----------
Let's test the function following an example taken from the documentation of the MultinomialNB model Let's test the function following an example taken from the documentation
from sklearn of the MultinomialNB model from sklearn
>>> rng = np.random.RandomState(1) >>> rng = np.random.RandomState(1)
>>> data = rng.randint(5, size=(6, 100)) >>> data = rng.randint(5, size=(6, 100))
>>> data = sparse.csr_matrix(data) >>> data = sparse.csr_matrix(data)