> 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-5-ml-pipelines-validation-and-testing/train-evaluate-ml-model-code-practice.md).

# 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
