# 4.6. Implementing custom metrics in Evidently \[OPTIONAL]

{% embed url="<https://youtu.be/uEyoP-sPhyc?si=7hwr4LaJIeBZ-YLD>" %}

**Video 6**. [Implementing custom metrics in Evidently \[OPTIONAL, CODE PRACTICE\]](https://youtu.be/uEyoP-sPhyc?si=7hwr4LaJIeBZ-YLD), by Emeli Dral

This is an optional code practice video. It is useful when you already have experience using the Evidently Python library and are familiar with the existing Metrics and Tests. If you are new - check out the next module for an end-to-end example!

**Want to go straight to code?** Here is the [example notebook](https://github.com/evidentlyai/ml_observability_course/blob/main/module4/custom_metric_practice.ipynb) to follow along.

**Outline:**\
[00:00](https://www.youtube.com/watch?v=uEyoP-sPhyc\&t=0s) Introduction\
[00:37](https://www.youtube.com/watch?v=uEyoP-sPhyc\&t=37s) Imports\
[01:54](https://www.youtube.com/watch?v=uEyoP-sPhyc\&t=114s) Understanding the structure of Metrics and Tests\
[05:11](https://www.youtube.com/watch?v=uEyoP-sPhyc\&t=311s) Create a dummy custom metric\
[12:17](https://www.youtube.com/watch?v=uEyoP-sPhyc\&t=737s) Apply a dummy metric on toy data\
[14:00](https://www.youtube.com/watch?v=uEyoP-sPhyc\&t=840s) Create a more complicated metric: Mean by Category\
[26:25](https://www.youtube.com/watch?v=uEyoP-sPhyc\&t=1585s) Apply a new metric on toy data


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.evidentlyai.com/ml-observability-course/module-4-designing-effective-ml-monitoring/custom-metrics-evidently-code-practice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
