Skip to content

Commit

Permalink
Bug-fix in AlgoEnsembleBestN and AlgoEnsembleBestbyFold (Project-MONA…
Browse files Browse the repository at this point in the history
…I#6300)

To solve: Project-MONAI#6299 

### Description

You can find the description of the changes in issue Project-MONAI#6299
  • Loading branch information
ValentinaVisani authored Apr 6, 2023
1 parent 332bfc0 commit 1832f95
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions monai/apps/auto3dseg/ensemble_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ def collect_algos(self, n_best: int = -1) -> None:
warn(f"Found {len(ranks)} available algos (pre-defined n_best={n_best}). All {len(ranks)} will be used.")
n_best = len(ranks)

# get the indices that the rank is larger than N
indices = [i for (i, r) in enumerate(ranks) if r >= n_best]
# get the ranks for which the indices are lower than N-n_best
indices = [r for (i, r) in enumerate(ranks) if i < (len(ranks) - n_best)]

# remove the found indices
indices = sorted(indices, reverse=True)
Expand Down Expand Up @@ -245,6 +245,7 @@ def collect_algos(self) -> None:
raise ValueError(f"model identifier {identifier} is not number.") from err
if algo_id == f_idx and algo[AlgoEnsembleKeys.SCORE] > best_score:
best_model = algo
best_score = algo[AlgoEnsembleKeys.SCORE]
self.algo_ensemble.append(best_model)


Expand Down

0 comments on commit 1832f95

Please sign in to comment.