# Custom metrics only mean value

**URL:** <https://discuss.ray.io/t/custom-metrics-only-mean-value/636>\
**Category:** RLlib\
**Created:** [January 28, 2021, 8:30am UTC](https://discuss.ray.io/t/custom-metrics-only-mean-value/636 "2021-01-28T08:30:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![skerres](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@skerres](https://discuss.ray.io/u/skerres)\
**Post date:** [January 28, 2021, 8:30am UTC](https://discuss.ray.io/t/custom-metrics-only-mean-value/636/1 "2021-01-28T08:30:51Z")

</div>

Hey, I am logging custom metrics from my ray tune run to tensorboard by overriding the `on_episode_end` function from `DefaultCallbacks` . For each value I have currently value\_mean, value\_max and value\_min, but I only want to save the value\_mean field. Is there a way to configure this? (edited)

---

<div class="post-metadata">

**Author:** ![sven1977](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sven1977/32/53_2.png) [@sven1977](https://discuss.ray.io/u/sven1977)\
**Post date:** [April 10, 2021, 1:24pm UTC](https://discuss.ray.io/t/custom-metrics-only-mean-value/636/2 "2021-04-10T13:24:17Z")

</div>

No, unfortunately, this is still pretty hard-coded to store mean/max/min values only.

---

<div class="post-metadata">

**Author:** ![mickelliu](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mickelliu/32/1347_2.png) [@mickelliu](https://discuss.ray.io/u/mickelliu)\
**Post date:** [February 15, 2022, 2:28pm UTC](https://discuss.ray.io/t/custom-metrics-only-mean-value/636/3 "2022-02-15T14:28:55Z")

</div>

Hi @sven1977, I have a similar question on this topic, but instead, I want to calculate and log the variance on a custom metric. Concretely, I have a few workers that will log some stats regarding the environment setting and I want to see how these stats vary across different workers. Is there a clean way to do this? I tried to look into `_process_trial` and `_process_trial_result` for some insights but I couldn’t figure out where does RLlib calculates those min/mean/max stats.

---

<div class="post-metadata">

**Author:** ![mickelliu](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mickelliu/32/1347_2.png) [@mickelliu](https://discuss.ray.io/u/mickelliu)\
**Post date:** [February 16, 2022, 1:06pm UTC](https://discuss.ray.io/t/custom-metrics-only-mean-value/636/4 "2022-02-16T13:06:54Z")

</div>

As I look into `metric_ops.py` deeper today I think I resolve my doubt. `CollectMetrics` stores a queue of episode history for the size of `min_history=100`, therefore it calculates a running mean with the window of 100 episodes.

I think perhaps this should be noted somewhere in the docs?
