Skip to content

Commit f7ae453

Browse files
committed
small tweaks in python script so that the previous changes work with uploaded numerical datatype
1 parent 19cea34 commit f7ae453

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/assets/bias-detection-python-code.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,10 @@ def run():
233233
234234
print(f"localDataType: {localDataType}")
235235
236+
columns_to_encode = [col for col in filtered_df.columns if col != bias_variable]
236237
if localDataType == 'categorical':
237238
encoder = OrdinalEncoder()
238-
columns_to_encode = [col for col in filtered_df.columns if col != bias_variable]
239239
filtered_df[columns_to_encode] = encoder.fit_transform(filtered_df[columns_to_encode])
240-
# filtered_df[filtered_df.columns] = encoder.fit_transform(filtered_df).astype("int64")
241240
242241
print("filtered_df.dtypes:")
243242
print(filtered_df.dtypes)
@@ -409,11 +408,10 @@ def run():
409408
print("test_df:")
410409
print(test_df)
411410
411+
test_df_pred = test_df[columns_to_encode]
412412
if localDataType == 'categorical':
413-
# decode X_test using the encoder
414-
test_df_pred = test_df[columns_to_encode]
413+
# decode X_test using the encoder
415414
decoded_X_test = encoder.inverse_transform(test_df_pred)
416-
417415
418416
# display the decoded DataFrame
419417
decoded_X_test = pd.DataFrame(decoded_X_test, columns=test_df_pred.columns)

0 commit comments

Comments
 (0)