@@ -53,8 +53,8 @@ def _joint_log_likelihood(self, X):
53
53
I.e. ``log P(c) + log P(x|c)`` for all rows x of X, as an array-like of
54
54
shape (n_samples, n_classes).
55
55
56
- Input is passed to _joint_log_likelihood as-is by predict,
57
- predict_proba and predict_log_proba .
56
+ predict, predict_proba, and predict_log_proba pass the input through
57
+ _check_X and handle it over to _joint_log_likelihood .
58
58
"""
59
59
60
60
@abstractmethod
@@ -140,7 +140,7 @@ class GaussianNB(_BaseNB):
140
140
Parameters
141
141
----------
142
142
priors : array-like of shape (n_classes,)
143
- Prior probabilities of the classes. If specified the priors are not
143
+ Prior probabilities of the classes. If specified, the priors are not
144
144
adjusted according to the data.
145
145
146
146
var_smoothing : float, default=1e-9
@@ -423,13 +423,13 @@ def _partial_fit(self, X, y, classes=None, _refit=False, sample_weight=None):
423
423
# Take into account the priors
424
424
if self .priors is not None :
425
425
priors = np .asarray (self .priors )
426
- # Check that the provide prior match the number of classes
426
+ # Check that the provided prior matches the number of classes
427
427
if len (priors ) != n_classes :
428
428
raise ValueError ("Number of priors must match number of classes." )
429
429
# Check that the sum is 1
430
430
if not np .isclose (priors .sum (), 1.0 ):
431
431
raise ValueError ("The sum of the priors should be 1." )
432
- # Check that the prior are non-negative
432
+ # Check that the priors are non-negative
433
433
if (priors < 0 ).any ():
434
434
raise ValueError ("Priors must be non-negative." )
435
435
self .class_prior_ = priors
@@ -523,6 +523,12 @@ def _check_X_y(self, X, y, reset=True):
523
523
return self ._validate_data (X , y , accept_sparse = "csr" , reset = reset )
524
524
525
525
def _update_class_log_prior (self , class_prior = None ):
526
+ """Update class log priors.
527
+
528
+ The class log priors are based on `class_prior`, class count or the
529
+ number of classes. This method is called each time `fit` or
530
+ `partial_fit` update the model.
531
+ """
526
532
n_classes = len (self .classes_ )
527
533
if class_prior is not None :
528
534
if len (class_prior ) != n_classes :
@@ -733,7 +739,7 @@ class MultinomialNB(_BaseDiscreteNB):
733
739
If false, a uniform prior will be used.
734
740
735
741
class_prior : array-like of shape (n_classes,), default=None
736
- Prior probabilities of the classes. If specified the priors are not
742
+ Prior probabilities of the classes. If specified, the priors are not
737
743
adjusted according to the data.
738
744
739
745
Attributes
@@ -988,7 +994,7 @@ class BernoulliNB(_BaseDiscreteNB):
988
994
If false, a uniform prior will be used.
989
995
990
996
class_prior : array-like of shape (n_classes,), default=None
991
- Prior probabilities of the classes. If specified the priors are not
997
+ Prior probabilities of the classes. If specified, the priors are not
992
998
adjusted according to the data.
993
999
994
1000
Attributes
@@ -1136,7 +1142,7 @@ class CategoricalNB(_BaseDiscreteNB):
1136
1142
If false, a uniform prior will be used.
1137
1143
1138
1144
class_prior : array-like of shape (n_classes,), default=None
1139
- Prior probabilities of the classes. If specified the priors are not
1145
+ Prior probabilities of the classes. If specified, the priors are not
1140
1146
adjusted according to the data.
1141
1147
1142
1148
min_categories : int or array-like of shape (n_features,), default=None
0 commit comments