Book Image

Machine Learning Automation with TPOT

By : Dario Radečić
Book Image

Machine Learning Automation with TPOT

By: Dario Radečić

Overview of this book

The automation of machine learning tasks allows developers more time to focus on the usability and reactivity of the software powered by machine learning models. TPOT is a Python automated machine learning tool used for optimizing machine learning pipelines using genetic programming. Automating machine learning with TPOT enables individuals and companies to develop production-ready machine learning models cheaper and faster than with traditional methods. With this practical guide to AutoML, developers working with Python on machine learning tasks will be able to put their knowledge to work and become productive quickly. You'll adopt a hands-on approach to learning the implementation of AutoML and associated methodologies. Complete with step-by-step explanations of essential concepts, practical examples, and self-assessment questions, this book will show you how to build automated classification and regression models and compare their performance to custom-built models. As you advance, you'll also develop state-of-the-art models using only a couple of lines of code and see how those models outperform all of your previous models on the same datasets. By the end of this book, you'll have gained the confidence to implement AutoML techniques in your organization on a production level.
Table of Contents (14 chapters)
1
Section 1: Introducing Machine Learning and the Idea of Automation
3
Section 2: TPOT – Practical Classification and Regression
8
Section 3: Advanced Examples and Neural Networks in TPOT

Developing a simple GUI web application

This section aims to demonstrate how the Flask framework can be used to develop a simple web application. The focus is shifted toward building an application that captures form data, which is then passed to our deployed machine learning API:

  1. To start, create the following directory structure:

    Figure 9.6 – Web application directory structure

    Most of the logic is handled in app.py, and the templates folder is used to store HTML files for the app – more on that in a bit.

  2. This time we'll organize the code a bit better, so you'll need to create an additional file for storing the environment variables. Inside the root directory (webapp), create a file called .env – and populate it with the following:
    SECRET_KEY=SecretKey
    HOST=0.0.0.0
    PORT=9000
    API_ENDPOINT=http://ec2-18-220-113-224.us-east-2.compute.amazonaws.com:8000/predict

    Creating a separate file like this is considered to be a best practice when developing...