> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-run-filter-ui-updates.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Optimizing multiple metrics

W\&B Sweeps optimize a single objective metric. To optimize multiple metrics in a single run, combine them into a weighted sum and use that combined value as the sweep objective.

```python theme={null}
with wandb.init() as run:
  # Log individual metrics
  metric_a = run.summary.get("metric_a", 0.5)
  metric_b = run.summary.get("metric_b", 0.7)
  # ... log other metrics as needed
  metric_n = run.summary.get("metric_n", 0.9)

  # Combine metrics with weights
  # Adjust weights according to your optimization goals
  # For example, if you want to give more importance to metric_a and metric_n:
  metric_combined = 0.3 * metric_a + 0.2 * metric_b + ... + 1.5 * metric_n
  run.log({"metric_combined": metric_combined})
```

After you log the combined metric, set it as the optimization objective in your sweep configuration:

```yaml theme={null}
metric:
  name: metric_combined
  goal: minimize
```

***

<Badge stroke shape="pill" color="orange" size="md">[Sweeps](/support/models/tags/sweeps)</Badge><Badge stroke shape="pill" color="orange" size="md">[Metrics](/support/models/tags/metrics)</Badge>
