Skip to content

Commit d98df1b

Browse files
author
avm19
committed
ColumnwiseNB: rename into
1 parent e748cf1 commit d98df1b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

sklearn/naive_bayes.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ class ColumnwiseNB(_BaseNB, _BaseComposition):
14731473
14741474
Parameters
14751475
----------
1476-
estimators : list of tuples
1476+
estimatorNBs : list of tuples
14771477
List of (name, estimatorNB, columns) tuples specifying the naive Bayes
14781478
estimators to be combined into a single naive Bayes meta-estimator.
14791479
@@ -1592,15 +1592,15 @@ class ColumnwiseNB(_BaseNB, _BaseComposition):
15921592
[0 0 1 0 2 2]
15931593
"""
15941594

1595-
_required_parameters = ["estimatorsNB"]
1595+
_required_parameters = ["estimatorNBs"]
15961596

15971597
def _log_message(self, name, idx, total):
15981598
if not self.verbose:
15991599
return None
16001600
return "(%d of %d) Processing %s" % (idx, total, name)
16011601

1602-
def __init__(self, estimators, priors=None, n_jobs=None, verbose=False):
1603-
self.estimators = estimators
1602+
def __init__(self, estimatorNBs, priors=None, n_jobs=None, verbose=False):
1603+
self.estimatorNBs = estimatorNBs
16041604
self.priors = priors
16051605
self.n_jobs = n_jobs
16061606
self.verbose = verbose
@@ -1634,12 +1634,12 @@ def _joint_log_likelihood(self, X):
16341634
def _validate_estimators(self, check_partial=False):
16351635
# Check if estimators have fit/partial_fit and jll methods
16361636
# Validate estimator names via _BaseComposition._validate_names(self, names)
1637-
if not self.estimators:
1637+
if not self.estimatorNBs:
16381638
raise ValueError(
16391639
"A list of naive Bayes estimators must be provided "
16401640
"in the form [(name, estimatorNB, columns), ... ]."
16411641
)
1642-
names, estimators, _ = zip(*self.estimators)
1642+
names, estimators, _ = zip(*self.estimatorNBs)
16431643
for e in estimators:
16441644
if (not check_partial) and (
16451645
not (hasattr(e, "fit") and hasattr(e, "_joint_log_likelihood"))
@@ -1671,7 +1671,7 @@ def _validate_column_callables(self, X):
16711671
# ColumnTransformer code.
16721672
all_columns = []
16731673
estimator_to_input_indices = {}
1674-
for name, _, columns in self.estimators:
1674+
for name, _, columns in self.estimatorNBs:
16751675
if callable(columns):
16761676
columns = columns(X)
16771677
all_columns.append(columns)
@@ -1743,7 +1743,7 @@ def _iter(self, *, fitted=False, replace_strings=False):
17431743
else:
17441744
yield (name, estimator, cols)
17451745
else: # fitted=False
1746-
for (name, estimator, _), cols in zip(self.estimators, self._columns):
1746+
for (name, estimator, _), cols in zip(self.estimatorNBs, self._columns):
17471747
if replace_strings and _is_empty_column_selection(cols):
17481748
continue
17491749
else:
@@ -1948,14 +1948,14 @@ def _estimators(self):
19481948
which expects lists of tuples of len 2.
19491949
"""
19501950
# Implemented in the image and likeness of ColumnTranformer._transformers
1951-
return [(name, e) for name, e, _ in self.estimators]
1951+
return [(name, e) for name, e, _ in self.estimatorNBs]
19521952

19531953
@_estimators.setter
19541954
def _estimators(self, value):
19551955
# Implemented in the image and likeness of ColumnTranformer._transformers
19561956
# TODO: Is renaming or changing the order legal? Swap `name` and `_`?
1957-
self.estimators = [
1958-
(name, e, col) for ((name, e), (_, _, col)) in zip(value, self.estimators)
1957+
self.estimatorNBs = [
1958+
(name, e, col) for ((name, e), (_, _, col)) in zip(value, self.estimatorNBs)
19591959
]
19601960

19611961
def get_params(self, deep=True):

0 commit comments

Comments
 (0)