8000 More docstring cleanup and minor fix · scikit-learn/scikit-learn@13db01f · GitHub
[go: up one dir, main page]

Skip to content

Commit 13db01f

Browse files
committed
More docstring cleanup and minor fix
Previously triggered a copy of class_prior_ on partial_fit; now assign into existing array.
1 parent 9ef2538 commit 13db01f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

sklearn/naive_bayes.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ class GaussianNB(BaseNB):
106106
107107
Attributes
108108
----------
109-
`class_prior_` : array, shape (n_classes)
109+
`class_prior_` : array, shape (n_classes,)
110110
probability of each class.
111111
112-
`class_count_` : array, shape (n_classes)
112+
`class_count_` : array, shape (n_classes,)
113113
number of training samples observed in each class.
114114
115115
`theta_` : array, shape (n_classes, n_features)
@@ -141,11 +141,11 @@ def fit(self, X, y):
141141
142142
Parameters
143143
----------
144-
X : array-like, shape = [n_samples, n_features]
144+
X : array-like, shape = (n_samples, n_features)
145145
Training vectors, where n_samples is the number of samples
146146
and n_features is the number of features.
147147
148-
y : array-like, shape = [n_samples]
148+
y : array-like, shape = (n_samples,)
149149
Target values.
150150
151151
Returns
@@ -193,21 +193,21 @@ def _update_mean_variance(n_past, mu, var, X):
193193
194194
Parameters
195195
----------
196-
n_past : scalar
196+
n_past : int
197197
Number of samples represented in old mean and variance.
198198
199-
mu: array-like, shape (number of Gaussians)
199+
mu: array-like, shape (number of Gaussians,)
200200
Means for Gaussians in original set.
201201
202-
var: array-like, shape (number of Gaussians)
202+
var: array-like, shape (number of Gaussians,)
203203
Variances for Gaussians in original set.
204204
205205
Returns
206206
-------
207-
mu_new: array-like, shape (number of Gaussians)
207+
mu_new: array-like, shape (number of Gaussians,)
208208
Updated mean for each Gaussian over the combined set.
209209
210-
var_new: array-like, shape (number of Gaussians)
210+
var_new: array-like, shape (number of Gaussians,)
211211
Updated variance for each Gaussian over the combined set.
212212
"""
213213
if n_past == 0:
@@ -249,10 +249,10 @@ def partial_fit(self, X, y, classes=None):
249249
Training vectors, where n_samples is the number of samples and
250250
n_features is the number of features.
251251
252-
y : array-like, shape (n_samples)
252+
y : array-like, shape (n_samples,)
253253
Target values.
254254
255-
classes : array-like, shape = (n_classes)
255+
classes : array-like, shape (n_classes,)
256256
List of all the classes that can possibly appear in the y vector.
257257
258258
Must be provided at the first call to partial_fit, can be omitted
@@ -295,7 +295,7 @@ def partial_fit(self, X, y, classes=None):
295295
self.class_count_[i] += N_i
296296

297297
self.sigma_[:, :] += epsilon
298-
self.class_prior_ = self.class_count_ / np.sum(self.class_count_)
298+
self.class_prior_[:] = self.class_count_ / np.sum(self.class_count_)
299299
return self
300300

301301
def _joint_log_likelihood(self, X):

0 commit comments

Comments
 (0)
0