Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix roc_auc #467

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion federatedscope/autotune/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def eval_in_fs(cfg, config, budget, client_cfgs=None):
from federatedscope.core.auxiliaries.worker_builder import \
get_client_cls, get_server_cls
from federatedscope.core.auxiliaries.runner_builder import get_runner
from federatedscope.autotune.utils import config2cmdargs
from os.path import join as osp

if isinstance(config, CS.Configuration):
Expand Down
7 changes: 4 additions & 3 deletions federatedscope/core/monitors/metric_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ def eval_roc_auc(y_true, y_prob, **kwargs):
if np.sum(y_true[:, i] == 1) > 0 and np.sum(y_true[:, i] == 0) > 0:
# ignore nan values
is_labeled = y_true[:, i] == y_true[:, i]
y_true_one_hot = np.eye(y_prob.shape[1])[y_true[is_labeled, i]]
# TODO: handle missing label classes
rocauc_list.append(
roc_auc_score(y_true_one_hot,
softmax(y_prob[is_labeled, :, i], axis=-1)))
roc_auc_score(y_true[is_labeled, i],
softmax(y_prob[is_labeled, :, i], axis=-1),
multi_class='ovr'))
if len(rocauc_list) == 0:
logger.warning('No positively labeled data available.')
return 0.5
Expand Down