Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

set fill value to max of full dataset + 1 #36

Merged
merged 1 commit into from
Mar 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions autoPyTorch/pipeline/nodes/imputation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def fit(self, hyperparameter_config, X, train_indices, dataset_info):
return {'imputation_preprocessor': None, 'all_nan_columns': None}

# delete all nan columns
all_nan = np.all(np.isnan(X[train_indices]), axis=0)
all_nan = np.all(np.isnan(X), axis=0)
X = X[:, ~all_nan]
dataset_info.categorical_features = [dataset_info.categorical_features[i] for i, is_nan in enumerate(all_nan) if not is_nan]

strategy = hyperparameter_config['strategy']
fill_value = int(np.nanmax(X[train_indices])) + 1 if not dataset_info.is_sparse else 0
fill_value = int(np.nanmax(X)) + 1 if not dataset_info.is_sparse else 0
numerical_imputer = SimpleImputer(strategy=strategy, copy=False)
categorical_imputer = SimpleImputer(strategy='constant', copy=False, fill_value=fill_value)
transformer = ColumnTransformer(
Expand Down Expand Up @@ -63,4 +63,4 @@ def get_pipeline_config_options(self):
ConfigOption(name='imputation_strategies', default=Imputation.strategies, type=str, list=True, choices=Imputation.strategies)
]
return options