> For the complete documentation index, see [llms.txt](https://learn.evidentlyai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.evidentlyai.com/ml-observability-course/module-4-designing-effective-ml-monitoring/custom-metrics-evidently-code-practice.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
