Skip to content

Commit

Permalink
Fix feature selection to return all columns instead of None if no con…
Browse files Browse the repository at this point in the history
…version happens
  • Loading branch information
ThomasMeissnerDS committed Oct 2, 2024
1 parent ad14f53 commit 400a69a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bluecast/preprocessing/feature_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,16 @@ def _BoostARoota(x, y, metric, clf, cutoff, iters, max_rounds, delta, silent):
silent=silent,
)

if len(keep_vars) == 0:
keep_vars = x.columns.to_list()

if crit | (i >= max_rounds):
break # exit and use keep_vars as final variables
else:
new_x = new_x[keep_vars].copy()
if len(keep_vars) > 0:
new_x = new_x[keep_vars].copy()
else:
new_x = new_x.copy()

Check warning on line 341 in bluecast/preprocessing/feature_selection.py

View check run for this annotation

Codecov / codecov/patch

bluecast/preprocessing/feature_selection.py#L341

Added line #L341 was not covered by tests
if not silent:
print("BoostARoota ran successfully! Algorithm went through ", i, " rounds.")
return keep_vars
1 change: 1 addition & 0 deletions bluecast/tests/test_feature_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_boostaroota_wrapper_multiclass():
boosta = BoostaRootaWrapper(class_problem="multiclass", random_state=45)
# Fit the model
trans_df, trans_targets = boosta.fit_transform(df, targets)
print(f"Final multiclass df is of shape: {trans_df.shape}")

assert trans_targets.equals(targets)

Expand Down
Binary file modified dist/bluecast-1.6.2-py3-none-any.whl
Binary file not shown.
Binary file modified dist/bluecast-1.6.2.tar.gz
Binary file not shown.

0 comments on commit 400a69a

Please sign in to comment.