# Optimize a nested metric

**URL:** https://discuss.ray.io/t/optimize-a-nested-metric/989
**Category:** Ray Tune
**Created:** [February 23, 2021, 11:14am UTC](https://discuss.ray.io/t/optimize-a-nested-metric/989 "2021-02-23T11:14:56Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![RaphaelCS](https://avatars.discourse-cdn.com/v4/letter/r/d07c76/32.png) [@RaphaelCS](https://discuss.ray.io/u/RaphaelCS)
#### Post date: [February 23, 2021, 11:14am UTC](https://discuss.ray.io/t/optimize-a-nested-metric/989/1 "2021-02-23T11:14:56Z")

</div>

I am working with rllib and tune but met some difficulties.  
I want to optimize a metric reported only by my customized evaluation, but all of the metrics reported by evaluation are nested in the reported result. So I can’t pass such a metric into tune.run() since it is not a key of reported result. Similarly, I can’t pass such a metric as ‘checkpoint\_score\_attr’ into tune.run() for the same reason.  
Is there any way to do the same thing as I want? Or may be we can add this new feature?

---

<div class="post-metadata">

### Author: ![kai](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kai/32/3380_2.png) [@kai](https://discuss.ray.io/u/kai)
#### Post date: [February 23, 2021, 2:51pm UTC](https://discuss.ray.io/t/optimize-a-nested-metric/989/2 "2021-02-23T14:51:28Z")

</div>

Hi Raphael, right, currently this is not supported. Can you instead pass the metric directly to `tune.report`? Like this

```auto
result = evaluate(...)
tune.report(metric=result["nested"]["metric"], **result)

```

and then pass `metric=metric` to `tune.run`?

---

<div class="post-metadata">

### Author: ![kai](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kai/32/3380_2.png) [@kai](https://discuss.ray.io/u/kai)
#### Post date: [February 23, 2021, 2:52pm UTC](https://discuss.ray.io/t/optimize-a-nested-metric/989/3 "2021-02-23T14:52:33Z")

</div>

Oh sorry, I just saw you’re using RLLib. In that case cc @sven1977 who might know where to do this best.

---

<div class="post-metadata">

### Author: ![RaphaelCS](https://avatars.discourse-cdn.com/v4/letter/r/d07c76/32.png) [@RaphaelCS](https://discuss.ray.io/u/RaphaelCS)
#### Post date: [February 25, 2021, 2:33am UTC](https://discuss.ray.io/t/optimize-a-nested-metric/989/4 "2021-02-25T02:33:25Z")

</div>

Thanks for mentioning him!

---

<div class="post-metadata">

### Author: ![RaphaelCS](https://avatars.discourse-cdn.com/v4/letter/r/d07c76/32.png) [@RaphaelCS](https://discuss.ray.io/u/RaphaelCS)
#### Post date: [February 26, 2021, 4:15am UTC](https://discuss.ray.io/t/optimize-a-nested-metric/989/5 "2021-02-26T04:15:16Z")

</div>

I pull request [here](https://github.com/ray-project/ray/pull/14375)

---

<div class="post-metadata">

### Author: ![kai](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kai/32/3380_2.png) [@kai](https://discuss.ray.io/u/kai)
#### Post date: [February 26, 2021, 4:12pm UTC](https://discuss.ray.io/t/optimize-a-nested-metric/989/6 "2021-02-26T16:12:47Z")

</div>

That’s awesome, thanks again!
