Skip to content

Commit

Permalink
fix two template (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
WinstonLiyt authored Sep 27, 2024
1 parent cead345 commit c1d94b5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def clean_and_impute_data(X_train, X_valid, X_test):
then imputes missing values using the mean strategy.
Also removes duplicate columns.
"""
# Replace inf and -inf with NaN
# Replace inf and -inf with NaNa
X_train.replace([np.inf, -np.inf], np.nan, inplace=True)
X_valid.replace([np.inf, -np.inf], np.nan, inplace=True)
X_test.replace([np.inf, -np.inf], np.nan, inplace=True)
Expand All @@ -68,9 +68,4 @@ def clean_and_impute_data(X_train, X_valid, X_test):
X_valid = pd.DataFrame(imputer.transform(X_valid), columns=X_valid.columns)
X_test = pd.DataFrame(imputer.transform(X_test), columns=X_test.columns)

# Remove duplicate columns
X_train = X_train.loc[:, ~X_train.columns.duplicated()]
X_valid = X_valid.loc[:, ~X_valid.columns.duplicated()]
X_test = X_test.loc[:, ~X_test.columns.duplicated()]

return X_train, X_valid, X_test
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ def import_module_from_path(module_name, module_path):

print(X_train.shape, X_valid.shape, X_test.shape)

# Handle inf and -inf values
X_train.replace([np.inf, -np.inf], np.nan, inplace=True)
X_valid.replace([np.inf, -np.inf], np.nan, inplace=True)
X_test.replace([np.inf, -np.inf], np.nan, inplace=True)

from sklearn.impute import SimpleImputer

imputer = SimpleImputer(strategy="mean")
Expand Down

0 comments on commit c1d94b5

Please sign in to comment.