# Autotune on custom model class

**URL:** <https://discourse.scverse.org/t/autotune-on-custom-model-class/2484>\
**Category:** scvi-tools\
**Created:** [August 29, 2024, 5:45pm UTC](https://discourse.scverse.org/t/autotune-on-custom-model-class/2484 "2024-08-29T17:45:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![emdann](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/emdann/32/254_2.png) [@emdann](https://discourse.scverse.org/u/emdann)\
**Post date:** [August 29, 2024, 5:45pm UTC](https://discourse.scverse.org/t/autotune-on-custom-model-class/2484/1 "2024-08-29T17:45:33Z")

</div>

Hi there,  
I am trying to use the `scvi.autotune` module on a custom model class based on `BaseModelClass`. I’ve followed [the tutorial](https://docs.scvi-tools.org/en/stable/tutorials/notebooks/tuning/autotune_new_model.html) and I am able to use the `TunableMixin` to customize the set of tunable parameters, but not for exposing additional metrics.

Can I use the mixin to expose more metrics? I would like to use other metrics reported in the training history for tuning (e.g. `elbo_validation`).

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![cane11](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/cane11/32/241_2.png) [@cane11](https://discourse.scverse.org/u/cane11)\
**Post date:** [August 29, 2024, 9:10pm UTC](https://discourse.scverse.org/t/autotune-on-custom-model-class/2484/2 "2024-08-29T21:10:33Z")

</div>

Hi, can you please use the current main? I inherited it from Martin and this seems more straightforward to me. Is it a metric that is anyhow tracked by your model (I assume so as you mention the model history) or do you want to have a custom callback to track another metric. First one is easy by passing in a list of metrics to run\_autotune in [scvi-tools/src/scvi/autotune/\_tune.py at main · scverse/scvi-tools · GitHub](https://github.com/scverse/scvi-tools/blob/main/src/scvi/autotune/_tune.py)

---

<div class="post-metadata">

**Author:** ![cane11](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/cane11/32/241_2.png) [@cane11](https://discourse.scverse.org/u/cane11)\
**Post date:** [August 29, 2024, 9:12pm UTC](https://discourse.scverse.org/t/autotune-on-custom-model-class/2484/3 "2024-08-29T21:12:23Z")

</div>

An example for the second one, you can find at: [Comparing main...metrics · scverse/scvi-tools · GitHub](https://github.com/scverse/scvi-tools/compare/main...metrics) (it is pretty involved to set it up), so if you think it’s of general use, we can provide some help to set up a new Callback.

---

<div class="post-metadata">

**Author:** ![emdann](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/emdann/32/254_2.png) [@emdann](https://discourse.scverse.org/u/emdann)\
**Post date:** [August 29, 2024, 11:41pm UTC](https://discourse.scverse.org/t/autotune-on-custom-model-class/2484/4 "2024-08-29T23:41:22Z")

</div>

Thank you @cane11 for the quick reply!  
I switched to the implementation in main and that does exactly what I need, to use another regularly tracked metric). I also agree that this implementation looks more straightforward than the one in the tutorial.

---

<div class="post-metadata">

**Author:** ![cane11](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/cane11/32/241_2.png) [@cane11](https://discourse.scverse.org/u/cane11)\
**Post date:** [August 30, 2024, 12:00am UTC](https://discourse.scverse.org/t/autotune-on-custom-model-class/2484/5 "2024-08-30T00:00:42Z")

</div>

Great and thanks for the feedback. Release will be in the next weeks.
