Skip to content

Crash at end of regression runs #57

Description

@mszulcz-mitre

When I make a run with cfg.dataset.task_type = 'regression', the code crashes at the end of the run. The error message is:

Traceback (most recent call last):
 File "main_pyg.py", line 55, in <module>
   agg_runs(cfg.out_dir, cfg.metric_best)
 File "~/Code/GraphGym/graphgym/utils/agg_runs.py", line 100, in agg_runs
   [stats[metric] for stats in stats_list])
 File "~/Code/GraphGym/graphgym/utils/agg_runs.py", line 100, in <listcomp>
   [stats[metric] for stats in stats_list])
KeyError: 'accuracy'

The problem seems to be that accuracy is not a metric logged for regression tasks. Here are the relevant lines in agg_runs.py:

                if metric_best == 'auto':
                    metric = 'auc' if 'auc' in stats_list[0] else 'accuracy'

Here's a fix:

                if metric_best == 'auto':
                    if cfg.dataset.task_type == 'classification':
                        metric = 'auc' if 'auc' in stats_list[0] else 'accuracy'
                    elif cfg.dataset.task_type == 'regression':
                        metric = 'mse'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions