Skip to content

Commit a978478

Browse files
authored
fix: modify show_models() to display same ranks as leaderboard (#1621)
1 parent 59ea4b0 commit a978478

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

autosklearn/automl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,21 +2185,20 @@ def has_key(rv, key):
21852185

21862186
table = pd.DataFrame.from_dict(table_dict, orient="index")
21872187
table.sort_values(by="cost", inplace=True)
2188+
table["rank"] = np.arange(1, len(table.index) + 1)
21882189

21892190
# Check which resampling strategy is chosen and selecting the appropriate models
21902191
is_cv = self._resampling_strategy == "cv"
21912192
models = self.cv_models_ if is_cv else self.models_
21922193

2193-
rank = 1 # Initializing rank for the first model
21942194
for (_, model_id, _), model in models.items():
21952195
model_dict = {} # Declaring model dictionary
21962196

21972197
# Inserting model_id, rank, cost and ensemble weight
21982198
model_dict["model_id"] = table.loc[model_id]["model_id"].astype(int)
2199-
model_dict["rank"] = rank
2199+
model_dict["rank"] = table.loc[model_id]["rank"].astype(int)
22002200
model_dict["cost"] = table.loc[model_id]["cost"]
22012201
model_dict["ensemble_weight"] = table.loc[model_id]["ensemble_weight"]
2202-
rank += 1 # Incrementing rank by 1 for the next model
22032202

22042203
# The steps in the models pipeline are as follows:
22052204
# 'data_preprocessor': DataPreprocessor,

0 commit comments

Comments
 (0)