Skip to content

Distinguish between target_metric and result_metrics  #135

@nihaase

Description

@nihaase

In config/study.py the target metric is defined as

target_metric: str | list[str] = field(validator=[validate_metric])

This creates type errors like

octopus/modules/efs/core.py:333: error: Argument 1 to "get_metric_function" of "MetricsInventory" has incompatible type "str | list[str]"; expected "str" [arg-type]

Current Problems:

  1. Type ambiguity: The str | list[str] union causes type errors everywhere
  2. Redundancy: There are already two fields doing similar things:
    - target_metric: str | list[str] - optimization metric (+ optional extras)
    - metrics: list - metrics to calculate (defaults to target_metric)
  3. Inconsistent usage: Different modules handle it differently:
    - EFS, SFS, RFE, Boruta, AutoGluon: str | list[str]
    - Training, Enssel, Bag: str only
  4. Unclear intent: When target_metric=["AUCROC", "ACC"], it's not obvious that only AUCROC is used for optimization

A possible solution would be to implement something like

  @define
  class ConfigStudy:
      target_metric: str = field(validator=[validate_metric])
      """The single metric used for optimization."""

      metrics_for_results: list[str] = field(
          default=Factory(lambda self: [self.target_metric], takes_self=True),
          validator=[validators.instance_of(list), validate_metric]
      )
      """Additional metrics to calculate for reporting (includes target_metric by default)."""

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions