Once you have 30 days of data from your freezer, you're ready to train a custom Machine Learning (ML) model! The goal of this model is to warn you before a freezer fails, giving you time to address the failure prior to losing critical work. To do this we'll use an auto-encoder algorithm.

Environment Setup

We'll use Python to train the model. If you're new to Python, check out this guide for a quick introduction.

We'll also use several machine learning Python libraries. We recommend using these in a virtual environment as this will keep your global installation of Python clean and keep all the dependencies for this project in one place.

Download the autoencoder_training.ipynb and either the win_python_venv.bat file for Windows or the mac_linux_python_venv.sh for Mac or Linux files from this repo. You may already have them if you cloned the repo in the previous step.

Python installation

You'll also need to install Python. Follow the links below to install Python for your appropriate operating system.

Python 3.8.6 Windows Installation

Python 3.8.6 Mac Installation

VS Code installation

You can use VS Code to view and run the Jupyter notebook that contains the anomaly detection training code. The notebook uses interactive Python, which walks you through the steps of the training the model. This guide will walk you through how to navigate Jupyter notebooks in VS Code Use this link to download and install VS Code. After you install VS Code you will also need to install the Python extension.

Python Virtual Environment Script

First open the Jupyter notebook in VS Code. Then open the terminal by pressing ctrl + shift + ` in the new terminal window type win_python_venv.bat or mac_linux_python_venv.sh and press enter.

Train Your Model

The rest of the tutorial is in the Jupyter notebook, make sure the new virtual environment you created is activated.

About Autoencoders

An autoencoder is a type of compression algorithm that works well on the type of data it's trained on, but not so well on any other data. For anomaly detection, you can use this characteristic of the algorithm to check whether new data is similar to or different than the training data used.

The model is built using two parts: 1) an encoder, which compresses the data, and 2) a decoder, which decompresses the data. Decompression allows you to check the accuracy of the re-created data. A high error rate in re-created data is likely an anomaly.

Further Reading

This guide was first published on Jan 27, 2021. It was last updated on Oct 27, 2020.

This page (Training an Anomaly Detector) was last updated on Jan 04, 2021.

Text editor powered by tinymce.