Leanpub Header

Skip to main content

Applied Machine Learning with PyTorch

A Hands-On, Project-Based Guide to Real-World Data Science

Machine learning doesn’t fail in theory—it fails in production. This book shows you how to build PyTorch systems that remain robust when data shifts, assumptions break, and reliability matters.

Minimum price

$19.00

$29.00

You pay

$29.00

Author earns

$23.20
$

...Or Buy With Credits!

You can get credits with a paid monthly or annual Reader Membership, or you can buy them here.
PDF
EPUB
About

About

About the Book

Most machine learning books end where real work begins—when a model performs well in a notebook. This book focuses on what happens after that point. It provides a practical view of applied machine learning with PyTorch, centered on the challenges that determine whether a system succeeds in production: data drift, shifting distributions, monitoring, failure analysis, and long-term maintainability.

Through domain-grounded projects in finance, retail, operations, and sports analytics, the book illustrates the engineering patterns that separate experimental code from production systems. Each chapter emphasizes robust workflows, clear mental models, and practices that help teams deliver reliable, real-world ML solutions.

Author

About the Author

Yusef Ulum

Yusef Ulum is a software engineer and systems thinker with 23 years of experience building applications across finance, telecommunications, embedded systems, and the web. Since 2023, he has focused on applied machine learning and AI. He writes about technology, history, and geopolitics, exploring how complex systems succeed, fail, and evolve.

Contents

Table of Contents

Preface

Who This Book Is For

Who This Book Is NOT For

Prerequisites

What You’ll Learn

How to Use This Book

Conventions

About the Author

Acknowledgments

Chapter 1: How Real-World ML Actually Breaks

  1. The Problem: The 99% Accuracy That Lost Millions
  2. Section 1: The Production-Reality Gap
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: Why PyTorch?
  6. Section 5: What This Book Covers
  7. Section 6: Common Pitfalls
  8. Section 7: Exercises
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 2: PyTorch: A Tool for People Who Want Control

  1. The Problem: When “It Just Works” Is Not Enough
  2. Prerequisites Refresher: Key Concepts
  3. Section 1: Problem Framing
  4. Section 2: Failure Analysis
  5. Section 3: Conceptual Model
  6. Section 4: PyTorch Implementation
  7. Section 5: Common Pitfalls
  8. Section 6: GPU Optimization
  9. Section 7: Exercises
  10. Section 8: Real-World Project
  11. Section 9: Constraints & Tradeoffs
  12. Section 10: References
  13. Summary
  14. Mental Model & Frameworks
  15. Accessibility Features

Chapter 3: The Working Data Scientist’s Workflow

  1. The Problem: The Workflow That Prevents Disasters
  2. Section 1: Problem Framing
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Monitoring from Day One
  8. Section 7: Exercises
  9. Section 8: Real-World Project
  10. Section 9: Constraints & Tradeoffs
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 4: Models That Still Win: Classical ML in 2026

  1. The Problem: When Transformers Aren’t the Answer
  2. Section 1: Problem Framing
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 5: Deep Learning for Structured & Tabular Data

  1. The Problem: When Deep Learning Finally Wins on Tabular Data
  2. Section 1: Problem Framing
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 6: Time, Sequences & Human Behavior

  1. The Problem: When Sequences Break Everything
  2. Section 1: Problem Framing
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 7: Finance — Price Movements & Market Regimes

  1. The Problem: Trying to Predict a Market That Adapts to You
  2. Section 1: Problem Framing
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 8: Retail — Sales Forecasting & Inventory Dynamics

  1. The Problem: Forecasting at Scale Without Losing the Signal
  2. Section 1: Problem Framing
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 9: Operations — Supply Chain ML That Doesn’t Collapse

  1. The Problem: When Averages Break the Supply Chain
  2. Section 1: Problem Framing
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 10: Sports Analytics — Modeling MMA/Football

  1. The Problem: Finding Signal in a Game Full of Noise
  2. Section 1: Problem Framing
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 11: Macroeconomics & Geopolitics — Modeling Uncertainty

  1. The Problem: When History Stops Being a Training Dataset
  2. Section 1: Problem Framing
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 12: Evaluating ML Beyond Accuracy

  1. The Problem: The 99.1% Accuracy That Destroyed Value
  2. Section 1: The Problem with Accuracy
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 13: Drift, Decay & the Strange Ways ML Degrades

  1. The Problem: The Model That Died While No One Was Watching
  2. Section 1: The Problem of Non-Stationarity
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 14: Packaging, Deployment & Interfaces

  1. The Problem: The Model That Worked in Notebooks But Failed in Production
  2. Section 1: The Deployment Challenge
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Mental Model & Frameworks
  14. Accessibility Features

Chapter 15: Silent Failures: The Ones That Steal Weekends

  1. The Problem: The Data Column Swap That Nobody Noticed
  2. Section 1: The Problem of Silent Failures
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Accessibility Features

Chapter 16: Debugging ML with Surgical Tools

  1. The Problem: The Model That Wasn’t Learning Anything
  2. Section 1: The Problem of Opaque Failures
  3. Section 2: Failure Analysis
  4. Section 3: Conceptual Model
  5. Section 4: PyTorch Implementation
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Accessibility Features

Chapter 17: ML in Enterprise: Governance, Interfaces & Trust

  1. The Problem: The Model That Wasn’t Allowed to Ship
  2. Section 1: The Enterprise Challenge
  3. Section 2: Governance Frameworks
  4. Section 3: Explainability and Transparency
  5. Section 4: Access Control and Multi-Tenancy
  6. Section 5: Common Pitfalls
  7. Section 6: Exercises
  8. Section 7: Real-World Project
  9. Section 8: Constraints & Tradeoffs
  10. Section 9: Chapter Checklist
  11. Section 10: References
  12. Summary
  13. Accessibility Features

Chapter 18: Scaling ML: From One Model to an Organization

  1. The Problem: The Platform That Couldn’t Scale
  2. Section 1: The Scaling Challenge
  3. Section 2: Platform Architecture
  4. Section 3: Multi-Model Management
  5. Section 4: Monitoring at Scale
  6. Section 5: Cost Optimization
  7. Section 6: Organizational Scaling
  8. Section 7: Common Pitfalls
  9. Section 8: Exercises
  10. Section 9: Real-World Project
  11. Section 10: Constraints & Tradeoffs
  12. Section 11: Chapter Checklist
  13. Section 12: References
  14. Summary
  15. Accessibility Features

Appendix A: PyTorch Cheatsheet

  1. Tensor Creation
  2. Tensor Operations
  3. Autograd: The Engine
  4. nn.Module: Building Blocks
  5. Loss Functions
  6. Optimizers
  7. DataLoader: Feeding the Model
  8. Common Patterns
  9. GPU Usage
  10. Moving Between Devices and Formats
  11. Debugging Tips

Appendix B: Project Skeleton

  1. Book Code Repository Structure
  2. Your Project Structure
  3. Directory Purpose
  4. Using TorchML in Your Project
  5. Essential Files
  6. Quick Start Commands

Appendix C: Model Comparison

  1. Classification by Data Type
  2. Tabular Data
  3. Sequence Data
  4. Image Data
  5. Multimodal
  6. Performance Benchmarks
  7. Selection Heuristics
  8. When to Switch
  9. Architecture Evolution

Appendix D: Diagnostics Checklist

  1. Phase 1: Data Validation
  2. Phase 2: Model Setup
  3. Phase 3: Training Loop
  4. Phase 4: Monitoring During Training
  5. Phase 5: Post-Training Validation
  6. Phase 6: Production Readiness
  7. Quick Diagnostic Script

Appendix E: Datasets & Code Index

  1. Code Repository
  2. Code Repository Structure
  3. TorchML Framework
  4. Quick Code Reference
  5. Quick Code Reference
  6. External Resources

Master Glossary

  1. Core ML Concepts
  2. Production ML Concepts
  3. Domain-Specific Concepts
  4. Evaluation & Metrics
  5. Time Series & Sequences
  6. Testing & Validation
  7. Governance & Operations
  8. Deep Learning & Architectures
  9. Alphabetical Index
  10. Quick Reference by Concept

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub