@@ -154,7 +154,16 @@ class labels known to the classifier
154
154
absolute additive value to variances
155
155
156
156
sigma_ : ndarray of shape (n_classes, n_features)
157
- variance of each feature per class
157
+ Variance of each feature per class.
158
+
159
+ .. deprecated:: 1.0
160
+ `sigma_` is deprecated in 1.0 and will be removed in 1.2.
161
+ Use `var_` instead.
162
+
163
+ var_ : ndarray of shape (n_classes, n_features)
164
+ Variance of each feature per class.
165
+
166
+ .. versionadded:: 1.0
158
167
159
168
theta_ : ndarray of shape (n_classes, n_features)
160
169
mean of each feature per class
@@ -377,7 +386,7 @@ def _partial_fit(self, X, y, classes=None, _refit=False,
377
386
n_features = X .shape [1 ]
378
387
n_classes = len (self .classes_ )
379
388
self .theta_ = np .zeros ((n_classes , n_features ))
380
- self .sigma_ = np .zeros ((n_classes , n_features ))
389
+ self .var_ = np .zeros ((n_classes , n_features ))
381
390
382
391
self .class_count_ = np .zeros (n_classes , dtype = np .float64 )
383
392
@@ -405,7 +414,7 @@ def _partial_fit(self, X, y, classes=None, _refit=False,
405
414
msg = "Number of features %d does not match previous data %d."
406
415
raise ValueError (msg % (X .shape [1 ], self .theta_ .shape [1 ]))
407
416
# Put epsilon back in each time
408
- self .sigma_ [:, :] -= self .epsilon_
417
+ self .var_ [:, :] -= self .epsilon_
409
418
410
419
classes = self .classes_
411
420
@@ -429,14 +438,14 @@ def _partial_fit(self, X, y, classes=None, _refit=False,
429
438
N_i = X_i .shape [0 ]
430
439
431
440
new_theta , new_sigma = self ._update_mean_variance (
432
- self .class_count_ [i ], self .theta_ [i , :], self .sigma_ [i , :],
441
+ self .class_count_ [i ], self .theta_ [i , :], self .var_ [i , :],
433
442
X_i , sw_i )
434
443
435
444
self .theta_ [i , :] = new_theta
436
- self .sigma_ [i , :] = new_sigma
445
+ self .var_ [i , :] = new_sigma
437
446
self .class_count_ [i ] += N_i
438
447
439
- self .sigma_ [:, :] += self .epsilon_
448
+ self .var_ [:, :] += self .epsilon_
440
449
441
450
# Update if only no priors is provided
442
451
if self .priors is None :
@@ -449,14 +458,22 @@ def _joint_log_likelihood(self, X):
449
458
joint_log_likelihood = []
450
459
for i in range (np .size (self .classes_ )):
451
460
jointi = np .log (self .class_prior_ [i ])
452
- n_ij = - 0.5 * np .sum (np .log (2. * np .pi * self .sigma_ [i , :]))
461
+ n_ij = - 0.5 * np .sum (np .log (2. * np .pi * self .var_ [i , :]))
453
462
n_ij -= 0.5 * np .sum (((X - self .theta_ [i , :]) ** 2 ) /
454
- (self .sigma_ [i , :]), 1 )
463
+ (self .var_ [i , :]), 1 )
455
464
joint_log_likelihood .append (jointi + n_ij )
456
465
457
466
joint_log_likelihood = np .array (joint_log_likelihood ).T
458
467
return joint_log_likelihood
459
468
469
+ @deprecated ( # type: ignore
470
+ "Attribute sigma_ was deprecated in 1.0 and will be removed in"
471
+ "1.2. Use var_ instead."
472
+ )
473
+ @property
474
+ def sigma_ (self ):
475
+ return self .var_
476
+
460
477
461
478
_ALPHA_MIN = 1e-10
462
479
0 commit comments