Chapter 7. Training Custom ML Models in Python

In this chapter, you’ll learn how to build classification models to predict customer churn using two popular ML libraries available in Python, scikit-learn and Keras. First, you’ll explore and clean your data using Pandas. Then you’ll learn how to use scikit-learn to prepare categorical features for training using one-hot encoding, train a logistic regression model, understand model performance using evaluation metrics, and improve model performance. You’ll learn how to perform the same steps using Keras to build a neural network classification model using the already prepared data. Along the way, you’ll learn more about performance metrics for classification models and how to better understand a confusion matrix to better evaluate your classification models.

The dataset being used for this chapter, the IBM Telco Customer Churn dataset, is a popular dataset for learning how to model customer churn. You should feel encouraged to look at other examples of how to work with this dataset to grow your knowledge after completing the exercises in this chapter.

The Business Use Case: Customer Churn Prediction

Your goal in this project will be to predict customer churn for a telecommunications company. Customer churn is defined as the attrition rate for customers, or in other words the rate of customers that choose to stop using services. Telecommunications companies often sell their products at a monthly rate or via annual contracts, so ...

Get Low-Code AI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.