# 5.2. Train and evaluate an ML model \[OPTIONAL CODE PRACTICE]

{% embed url="<https://youtu.be/wHBL9zFgA8U?si=7jzJdynEt6tzAKLN>" %}

**Video 2**. [Train and evaluate an ML model \[OPTIONAL CODE PRACTICE\]](https://youtu.be/wHBL9zFgA8U?si=7jzJdynEt6tzAKLN), by Emeli Dral

In this video, we prepare the data, train, evaluate, and save an ML model that we will use later in this module to deploy an end-to-end pipeline for data and ML model quality checks.

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

**Outline:**\
[00:00](https://www.youtube.com/watch?v=wHBL9zFgA8U\&t=0s) Introduction\
[00:39](https://www.youtube.com/watch?v=wHBL9zFgA8U\&t=39s) Imports\
[01:44](https://www.youtube.com/watch?v=wHBL9zFgA8U\&t=104s) Load and preview the raw data\
[05:02](https://www.youtube.com/watch?v=wHBL9zFgA8U\&t=302s) Feature engineering function\
[17:33](https://www.youtube.com/watch?v=wHBL9zFgA8U\&t=1053s) Split into train, reference and production\
[19:48](https://www.youtube.com/watch?v=wHBL9zFgA8U\&t=1188s) Transform raw data into pre-processed (and some debugging!)\
[23:00](https://www.youtube.com/watch?v=wHBL9zFgA8U\&t=1380s) Model training\
[27:28](https://www.youtube.com/watch?v=wHBL9zFgA8U\&t=1648s) Evaluate model quality


---

# 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-5-ml-pipelines-validation-and-testing/train-evaluate-ml-model-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.
