Preface
1.The Need for Machine Learning Design Patterns
What Are Design Patterns?
How to Use This Book
Machine Learning Terminology
Models and Frameworks
Data and Feature Engineering
The Machine Learning Process
Data and Model Tooling
Roles
Common Chauenges in Machine Learning
Data Quality
Reproducibility
Data Drift
Scale
Multiple Objectives
Summary
2.Data Representation Design Patterns
Simple Data Representations
Numerical Inputs
Categorical Inputs
Design Pattern 1: Hashed Feature
Problem
Solution
Why It Works
Trade-Offs and Alternatives
Design Pattern 2: Embeddings
Problem
Solution
Why It Works
Trade-Offs and Alternatives
Design Pattern 3: Feature Cross
Problem
Solution
Why It Works
Trade-Offs and Alternatives
Design Pattern 4: Multimodallnput
Problem
Solution
Trade-Offs and Alternatives
Summary
3.Problem Representation Design Patterns
Design Pattern 5: Reframing
Problem
Solution
Why It Works
Trade-Offs and Alternatives
Design Pattern 6: Multilabel
Problem
Solution
Trade-Offs and Alternatives
Design Pattern 7: Ensembles
Problem
Solution
Why It Works
Trade-Offs and Alternatives
Design Pattern 8: Cascade
Problem
Solution
Trade-Offs and Alternatives
Design Pattern 9: Neutral Class
Problem
Solution
Why It Works
Trade-Offs and Alternatives
Design Pattern 10: Re alanang
Problem
……
4.ModeI Training Patterns...
5.Design Patterns for Resilient Serving
6.Reproduability Design Patterns
7.Responsible AI
8.Connected Patterns
Index
Whols This Book For?
Introductory machine learning books usually focus on the what and how of machine learning (ML). They then explain the mathematical aspects of new methods from AI research labs and teach how to use AI frameworks to implement these methods. This book, on the other hand, brings together hard-earned experience around the "why"that underlies the tips and tricks that experienced ML practitioners employ when applying machine learning to real-world problems.
We assume that you have prior knowledge of machine learning and data processing.This is not a fundamental textbook on machine learning. Instead, this book is for you if you are a data scientist, data engineer, or ML engineer who is looking for a second book on practical machine learning. If you already know the basics, this book will introduce you to a catalog ofideas, some of which you (an ML practitioner) may rec-ognize, anc:give those ideas a name so that you can confldently reach for them.If you are a computer saence student headed for a job in industry, this book will round out your knowledge and prepare you for the professional world. It will help you learn how to build high-quality ML systems.
What's Notin the Book
This is a book that is primarily for ML engineers in the enterprise, not ML scientists in academia or industry research labs.
We purposefully do not discuss areas of active research-you will fmd very little here,for example, on machine learning model architecture (bidirectional encoders, or the attention mechanism, or short-circuit layers, for example) because we assume that you will be using a pre-built model architecture (such as ResNet-50 or GRUCell), not writing your own image classification or recurrent neural network.
Here are some concrete examples of areas that we intentionally stay away from because we believe that these topics are more appropriate for college courses and ML researchers:
ML algorithmsWe do not cover the differences between random forests and neural networks,for example. This is covered in introductory machine learning textbooks.Building blocksWe do not cover different types of gradient descent optimizers or activation functions. We recommend using Adam and ReLU-in our experience, thepotential for improvements in performance by making different choices in these sorts of things tends to be minor.
ML model architectures
Ifyou are doing image classiFication, we recommend that you use an off-the-shelf model like ResNet or whatever the latest hotness is at the time you are reading this. Leave the design of new image classification or text classification models to researchers who specialize in this problem.
Model layers
You won't fmd convolutional neural networks or recurrent neural networks in this book. They are doubly disqualified-first, for being a building block and sec-ond, for being something you can use off-the-shelf.
Custom training loops
Just calling model. fit()in Keras will Fit the needs of practitioners.In this book, we have tried to include only common patterns of the kind that machine learning engineers in enterprises will employ in their day-to-day work.As an analogy, consider data structures. While a college course on data structures will delve into the implementations of different data structures, and a researcher on data structures will have to learn how to formally represent their mathematical properties,the practitioner can be more pragmatic. An enterprise software developer simply needs to know how to work effectively with arrays, linked lists, maps, sets, and trees.It is for a pragmatic practitioner in machine learning that this book is written.