Skip to content

Commit e6d0490

Browse files
committed
[refactor] Rename transformed_columns --> enc_columns
1 parent a679b09 commit e6d0490

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

autoPyTorch/data/base_feature_validator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class BaseFeatureValidator(BaseEstimator):
2626
column_transformer (Optional[BaseEstimator])
2727
Host a encoder object if the data requires transformation (for example,
2828
if provided a categorical column in a pandas DataFrame)
29-
transformed_columns (List[str])
30-
List of columns that were encoded.
29+
enc_columns (Optional[List[str]]):
30+
The list of column names that should be encoded.
3131
"""
3232
def __init__(
3333
self,
@@ -40,7 +40,7 @@ def __init__(
4040
self.column_order: List[str] = []
4141

4242
self.column_transformer: Optional[BaseEstimator] = None
43-
self.transformed_columns: List[str] = []
43+
self.enc_columns: List[str] = []
4444

4545
self.logger: Union[
4646
PicklableClientLogger, logging.Logger

autoPyTorch/data/tabular_feature_validator.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class TabularFeatureValidator(BaseFeatureValidator):
8585
List for which an element at each index is a
8686
list containing the categories for the respective
8787
categorical column.
88-
transformed_columns (List[str])
88+
enc_columns (List[str])
8989
List of columns that were transformed.
9090
column_transformer (Optional[BaseEstimator])
9191
Hosts an imputer and an encoder object if the data
@@ -174,16 +174,16 @@ def _fit(
174174
if not X.select_dtypes(include='object').empty:
175175
X = self.infer_objects(X)
176176

177-
self.transformed_columns, self.feat_type = self._get_columns_to_encode(X)
177+
self.enc_columns, self.feat_type = self._get_columns_to_encode(X)
178178

179179
assert self.feat_type is not None
180180

181-
if len(self.transformed_columns) > 0:
181+
if len(self.enc_columns) > 0:
182182

183183
preprocessors = get_tabular_preprocessors()
184184
self.column_transformer = _create_column_transformer(
185185
preprocessors=preprocessors,
186-
categorical_columns=self.transformed_columns,
186+
categorical_columns=self.enc_columns,
187187
)
188188

189189
# Mypy redefinition
@@ -373,7 +373,7 @@ def _check_data(
373373

374374
# Define the column to be encoded here as the feature validator is fitted once
375375
# per estimator
376-
self.transformed_columns, self.feat_type = self._get_columns_to_encode(X)
376+
self.enc_columns, self.feat_type = self._get_columns_to_encode(X)
377377

378378
column_order = [column for column in X.columns]
379379
if len(self.column_order) > 0:
@@ -411,17 +411,17 @@ def _get_columns_to_encode(
411411
checks) and an encoder fitted in the case the data needs encoding
412412
413413
Returns:
414-
transformed_columns (List[str]):
414+
enc_columns (List[str]):
415415
Columns to encode, if any
416416
feat_type:
417417
Type of each column numerical/categorical
418418
"""
419419

420-
if len(self.transformed_columns) > 0 and self.feat_type is not None:
421-
return self.transformed_columns, self.feat_type
420+
if len(self.enc_columns) > 0 and self.feat_type is not None:
421+
return self.enc_columns, self.feat_type
422422

423423
# Register if a column needs encoding
424-
transformed_columns = []
424+
enc_columns = []
425425

426426
# Also, register the feature types for the estimator
427427
feat_type = []
@@ -430,7 +430,7 @@ def _get_columns_to_encode(
430430
for i, column in enumerate(X.columns):
431431
if X[column].dtype.name in ['category', 'bool']:
432432

433-
transformed_columns.append(column)
433+
enc_columns.append(column)
434434
feat_type.append('categorical')
435435
# Move away from np.issubdtype as it causes
436436
# TypeError: data type not understood in certain pandas types
@@ -472,7 +472,7 @@ def _get_columns_to_encode(
472472
)
473473
else:
474474
feat_type.append('numerical')
475-
return transformed_columns, feat_type
475+
return enc_columns, feat_type
476476

477477
def list_to_dataframe(
478478
self,

0 commit comments

Comments
 (0)