Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorHannes Hapke, Catherine Nelson

Companies are spending billions on machine learning projects, but it's money wasted if the models can't be deployed effectively. In this practical guide, Hannes Hapke and Catherine Nelson walk you through the steps of automating a machine learning pipeline using the TensorFlow ecosystem. You'll learn the techniques and tools that will cut deployment time from days to minutes, so that you can focus on developing new models rather than maintaining legacy systems. Data scientists, machine learning engineers, and DevOps engineers will discover how to go beyond model development to successfully productize their data science projects, while managers will better understand the role they play in helping to accelerate these projects. The book also explores new approaches for integrating data privacy into machine learning pipelines. Understand the machine learning management lifecycle Implement data pipelines with Apache Airflow and Kubeflow Pipelines Work with data using TensorFlow tools like ML Metadata, TensorFlow Data Validation, and TensorFlow Transform Analyze models with TensorFlow Model Analysis and ship them with the TFX Model Pusher Component after the ModelValidator TFX Component confirmed that the analysis results are an improvement Deploy models in a variety of environments with TensorFlow Serving, TensorFlow Lite, and TensorFlow.js Learn methods for adding privacy, including differential privacy with TensorFlow Privacy and federated learning with TensorFlow Federated Design model feedback loops to increase your data sets and learn when to update your machine learning models

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Building Machine Learning Pipelines: Automating Model Life Cycles with TensorFlow ## 【One-Line Pitch】 A practical, hands-on guide for data scientists and ML engineers who want to move beyond one-off model training and productize their work using the TensorFlow Extended (TFX) ecosystem—covering everything from data ingestion and validation to deployment, monitoring, and privacy. If you've ever trained a great model that never made it into production, this book shows you how to build the automated pipeline that gets it there. ## 【Book Arc】 - **Opening (~0%–9%)**: Introduces the core problem—models that can't be deployed effectively are wasted investment—and lays out the machine learning management lifecycle. The authors define what an automated, reproducible pipeline should include (data versioning, validation, preprocessing, training, analysis, deployment, scaling, feedback loops) and introduce their running example project: predicting whether consumer complaints to the US Consumer Finance Protection Bureau are disputed, using a mix of structured and unstructured data. - **Early (~9%–28%)**: Dives into TensorFlow Extended (TFX) fundamentals, explaining how pipeline components work internally (driver, executor, publisher) and how they communicate through a metadata store. Covers installation, the Apache Beam programming model for distributed data processing, and the core concept of directed acyclic graphs (DAGs) for pipeline orchestration. - **Early–Middle (~28%–38%)**: Walks through data ingestion in detail—converting CSV data to tf.Example structures with CsvExampleGen, querying BigQuery and Presto databases, and handling image data for computer vision problems (with the practical tip to store compressed images as byte strings rather than decoding them). - **Middle (~38%–47%)**: Focuses on data validation with TensorFlow Data Validation (TFDV)—generating statistics for numerical and categorical features, detecting data drift and skew using L-infinity norm comparators, and checking for biased datasets. Shows how to integrate these checks into the pipeline via the StatisticsGen component. - **Late (~47%–end)**: Covers the remaining pipeline stages: model analysis and validation, deployment with TensorFlow Serving/Lite/JS, designing feedback loops to capture new training data and model performance metrics, and data privacy techniques including differential privacy with TensorFlow Privacy and federated learning with TensorFlow Federated. ## 【Key Takeaways】 - **Automated pipelines are the difference between one-off models and production systems** (Early): Without automation, ML projects degrade over time as data changes, data scientists spend their time fixing errors, and models don't get widely used. A proper pipeline versions data, validates inputs, trains, analyzes, deploys, scales, and captures feedback—all reproducibly. - **TFX components follow a consistent three-part structure** (Early): Every component has a driver (queries the metadata store), an executor (performs the actual work), and a publisher (saves output metadata). Understanding this pattern makes it easy to reason about any TFX component you encounter. - **Data ingestion is the foundation—get it right or nothing else matters** (Early–Middle): TFX provides ExampleGen components for different sources: CsvExampleGen for files, BigQueryExampleGen for Google BigQuery, and PrestoExampleGen for Presto databases. For images, store compressed files as byte strings in TFRecord format rather than decoding them (decoding wastes disk space). - **Data validation catches problems before they poison your model** (Middle): TensorFlow Data Validation computes statistics (counts, missing values, mean, std dev, min/max, histograms for numerical features; counts, missing percentages, unique values for categorical features) and can compare datasets to detect drift and skew using L-infinity norm thresholds. This is how you catch biased or unrepresentative data early. - **Bias detection is a concrete, checkable step—not just a principle** (Middle): Selection bias (where dataset distribution doesn't match real-world distribution) can be spotted using TFDV statistics visualizations—for example, checking that the distribution of complaints across US states reflects relative state populations. - **Privacy can be engineered into the pipeline, not bolted on afterward** (Late): The book covers differential privacy (with TensorFlow Privacy's differentially private optimizers and epsilon/delta privacy budgets), federated learning (with TensorFlow Federated), and encrypted machine learning for serving encrypted predictions—giving you options depending on your threat model and regulatory requirements. - **Feedback loops close the cycle** (Late): Designing systems where users rate or correct predictions, crowdsourced annotations, and automatically produced feedback feed new training data back into the pipeline—and you need explicit tracking of both explicit and implicit feedback to know when to retrain. ## 【Reading Tips】 - **Skim the preface and early chapters if you're already familiar with ML basics**—the book assumes you know model architecture selection and points you to other resources (like Aurélien Géron's book) if you need a refresher. The value starts when they get into TFX specifics. - **Deep-read the data ingestion and validation chapters (roughly 25%–47%)**—these are the most detailed and practical sections, with concrete code examples for CsvExampleGen, BigQueryExampleGen, PrestoExampleGen, and TFDV statistics/drift detection. This is where you'll learn patterns you can immediately apply. - **Follow along with the example project**—the book uses a public consumer complaints dataset from the Consumer Finance Protection Bureau, and the code is available on GitHub. Clone the repo and run the examples as you read; the interactive Jupyter Notebook execution mode makes this particularly easy. - **Pay attention to version notes**—the book was written with Python 3.6–3.8, TensorFlow 2.2.0, and TFX 0.22.0, and some components (like BigQueryExampleGen) changed import paths in later versions. Check the GitHub repo for updates if you're using newer versions. - **Skim the privacy chapter if you're not under regulatory pressure**—it's valuable, but the differential privacy and federated learning content is somewhat self-contained and can be read later when you actually need it. ## 【Coverage Limits】 This guide covers the book's opening through the data validation stage (~47% of the book) in detail. The later chapters on model analysis, deployment, feedback loops, and privacy are summarized at a high level based on the table of contents and early excerpts; specific code examples and implementation details from those sections are not covered here. ##
Page 7
eword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii Preface. ....
View in text
Excerpt 2
achine learning examples in xviii | Preface Acknowledgments We’ve had so much support from many wonderful people throughout the process of writing this book....
View in text
Excerpt 3
ded with beam.Pipeline() as p: output | beam.io.WriteToText(output_file) Write the output to the file output_file. Basic transformation example In Apache Bea...
View in text
Excerpt 4
g with our data input pipeline. Because the L-infinity norm only returns a single number, the schema may be more useful for detecting variations between data...
View in text
Excerpt 5
and represented as a fixed graph during the training phase. If we use the Transform component from TFX in our pipeline, it expects the transfor‐ mation code...
View in text
Excerpt 6
a.take(1000) eval_examples = [tf.train.Example.FromString(d.numpy()) for d in subset] Next, we load the model and define a prediction function that takes in...
View in text
Excerpt 7
“protocol” used by today’s web services. It isn’t a formal protocol, but more a communication style that defines how clients communicate with web services. R...
View in text
Excerpt 8
ets’ web interface or through command-line copy operations. Any changes to model versions will be discovered by the serving instances. A new build of the mod...
View in text
Tags
AI categories
machine learningtensorflowmlops
ISBN: 1492053198
Publisher: O'Reilly Media
Publish Year: 2020
Language: English
Pages: 367
File Format: PDF
File Size: 15.7 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…