Skip to content

Commit 6d52e3a

Browse files
author
Sergey Feldman
committed
fix multiclass/binary metrics
1 parent d618102 commit 6d52e3a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

03_autogluon.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ def define_and_evaluate_autogluon_pipeline(X, y, random_state=0):
2121
for train_inds, test_inds in outer_cv.split(X, y):
2222
data_df_train = data_df.iloc[train_inds, :]
2323
data_df_test = data_df.iloc[test_inds, :]
24+
if len((set(y))) == 2:
25+
eval_metric = 'roc_auc'
26+
else:
27+
eval_metric = 'f1_weighted' # no multiclass auroc in autogluon
2428
predictor = task.fit(
2529
data_df_train,
2630
"y",
2731
time_limits=SEC,
2832
auto_stack=True,
2933
output_directory=".autogluon_temp",
30-
eval_metric="f1_weighted",
34+
eval_metric=eval_metric,
3135
verbosity=0,
3236
)
3337
y_pred = predictor.predict_proba(data_df.iloc[test_inds, :])
@@ -58,7 +62,7 @@ def define_and_evaluate_autogluon_pipeline(X, y, random_state=0):
5862
elapsed = time.time() - start
5963
times.append(elapsed)
6064
print("done. elapsed:", elapsed)
61-
print(f"AutoGluone score: {np.mean(nested_scores)}, Random Forest score: {np.mean(random_forest_results[i])}")
65+
print(f"AutoGluon score: {np.mean(nested_scores)}, Random Forest score: {np.mean(random_forest_results[i])}")
6266

6367
#
6468
results = np.array(results)

0 commit comments

Comments
 (0)