Hands-On AI & Programming

The 40 Best Hands-On AI and Programming Books (2026)

Forty code-first books for engineers, analysts and students who learn AI by building it, from foundation-model applications and LLMs written from scratch to the statistics, data systems and experiments beneath them.

As an Amazon Associate, Best AI Books earns from qualifying purchases. Best AI Books is sponsored by Iternal.ai, whose founder and CEO, John Byron Hanby IV, wrote The AI Strategy Blueprint, our #1 ranked book. How we rank books.

Quick picks

  • Best overall

    AI Engineering

    Covers evaluation, prompting, retrieval, finetuning and inference optimization in one systematic book, with the strongest evaluation chapters available to teams building on foundation models.

  • Best for LLM internals

    Build a Large Language Model (From Scratch)

    Readers write a GPT-style model in plain PyTorch, pretrain it, load GPT-2 weights and fine-tune it, all on an ordinary modern laptop.

  • Best for beginners

    R for Data Science

    The only beginner-level title in the group teaches tidy data, ggplot2 visualization and dplyr transformation in R, and the full second edition is free online.

Hands-on AI books teach by having the reader write and run code: tokenizers, training loops, retrieval pipelines, evaluation harnesses and production services. They differ from strategy books because every chapter produces something that executes, and from library documentation because they explain why a technique works and when it fails. These forty titles cover the full stack a working practitioner touches, from applications built on foundation models to the statistics, data engineering and experimentation that determine whether those applications can be trusted.

GitHub's Octoverse 2024 report found that Python overtook JavaScript as the most used language on the platform, a shift GitHub tied to the generative AI boom, and that developers created more than 70,000 new public and open source generative AI projects that year. The 2025 Stack Overflow Developer Survey found that 84% of respondents use or plan to use AI tools in development, yet more developers distrust the accuracy of those tools (46%) than trust it (33%). Developers who cannot take model output on faith need ways to measure it, and several books here, led by Chip Huyen's AI Engineering, devote whole chapters to evaluation and verification.

Who the books serve and how to read them

The ranking serves four groups: software engineers moving into AI work, ML engineers who need depth on large language models, data scientists and analysts who want a firmer statistical base, and data and platform engineers who build the pipelines that feed models. Most of the coding titles use Python; R for Data Science and Statistical Rethinking use R, while the data architecture and experimentation books teach concepts with little code.

Readers should enter by goal. Engineers shipping products on foundation models should start with AI Engineering, then add Hands-On Large Language Models or LLM Engineer's Handbook for implementation detail. Readers who want to see inside a model should work through Build a Large Language Model (From Scratch) and then its follow-up on reasoning models. Analysts building a foundation should pair An Introduction to Statistical Learning with Python for Data Analysis or R for Data Science. Teams putting models into production should read Designing Machine Learning Systems, Designing Data-Intensive Applications and Trustworthy Online Controlled Experiments, which together cover deployment, data infrastructure and measurement. Agent builders should start with Generative AI Design Patterns and Agentic Design Patterns.

Several strong titles cost nothing to read. The authors of R for Data Science, Python for Data Analysis, Python Data Science Handbook, Dive into Deep Learning and the third edition of Deep Learning with Python publish online editions free of charge, and PDFs of An Introduction to Statistical Learning are available from the authors' site. Code-first books also age faster than conceptual ones, because library APIs change. Before buying, check that the edition is current and that the authors' code repository still runs against recent library versions.

Ranked No. 1 overall

No. 01 of 500 · AI Strategy & Leadership

The AI Strategy Blueprint

John Byron Hanby IV · 2026 · More than 2 million copies delivered

Editorial score: 96.5/100

The ranking

  1. Rank 01

    AI Engineering

    Chip Huyen · 2025

    Generative AI & LLMs

    Chip Huyen's book ranks first because it covers the whole job of building on foundation models, with chapters on evaluation methodology, prompt engineering, retrieval-augmented generation and agents, finetuning, dataset engineering and inference optimization. Its two evaluation chapters stand out, explaining why open-ended outputs resist conventional tests and how to validate AI judges against human ratings.

    Readers get a decision framework more than code recipes: prompt first, add retrieval when the model lacks information, and finetune when behavior or format is the problem. Huyen's companion repository collects chapter summaries, case studies and resources, and the book has been translated into at least a dozen languages.

  2. Rank 02

    Build a Large Language Model (From Scratch)

    Sebastian Raschka · 2024

    Generative AI & LLMs

    Sebastian Raschka's book ranks second because it has readers write every component of a GPT-style model themselves in PyTorch, without existing LLM libraries. The sequence runs from tokenization and sliding-window data loading through self-attention with causal masking and pretraining, then loads OpenAI's released GPT-2 weights and fine-tunes the network into a text classifier and an instruction-following assistant.

    Manning states that the resulting model runs on any modern laptop, with GPUs optional. The book's code repository has passed 100,000 GitHub stars and holds the full code for every chapter.

  3. Rank 03

    An Introduction to Statistical Learning

    Gareth James, Daniela Witten, Trevor Hastie, Robert Tibshirani, Jonathan Taylor · 2013

    Machine Learning

    An Introduction to Statistical Learning ranks third because it gives analysts and engineers the predictive-modeling intuition that later books assume, with enough mathematics to explain each method and no more. Readers learn why flexible models need more data, how cross-validation and the bootstrap estimate test error, when ridge regression and the lasso help, and why tree ensembles often predict better than a single tree while explaining less.

    Chapters close with hands-on labs. The R edition first appeared in 2013, a second R edition followed in 2021 and a Python edition in 2023, and PDFs are available from the authors' official site.

  4. Rank 04

    Hands-On Large Language Models

    Jay Alammar, Maarten Grootendorst · 2024

    Generative AI & LLMs

    Jay Alammar and Maarten Grootendorst wrote one of the most visual books in the group, with more than 250 custom figures explaining tokens, embeddings, attention and the transformer. It ranks fourth because it moves quickly from those mechanics to work practitioners ship: classification and topic modeling with embedding models, semantic search, retrieval-augmented generation with reranking, and fine-tuning.

    The closing chapters show how LoRA and QLoRA bring generative-model fine-tuning within reach of a single consumer or free cloud GPU. Readers who learn best from diagrams can pair it with Raschka's from-scratch build, and the authors' book site links the code repository.

  5. Rank 05

    Deep Learning with Python

    François Chollet, Tomasz Kalinowski, J. J. Allaire · 2017

    François Chollet, the creator of Keras, teaches deep learning as chains of tensor operations tuned by gradient descent, which makes later architectures easier to follow. Every project follows the same workflow, from defining a success metric to beating a baseline and then regularizing, and readers can reuse that workflow in their own work.

    The third edition covers transformers, building a GPT-like language model and diffusion-based image generation, with examples in Keras, PyTorch, TensorFlow and JAX, and it is free to read online. Chollet's argument that current models generalize locally and lack humanlike abstraction gives readers a clear account of deep learning's limits.

  6. Rank 06

    Build a Reasoning Model (From Scratch)

    Sebastian Raschka · 2026

    Generative AI & LLMs

    Sebastian Raschka's follow-up is one of the most advanced titles in the group, written for readers who already understand how an LLM is pretrained. Starting from a conventional pretrained model, it implements inference-time techniques such as self-consistency voting and Best-of-N selection, and it builds math verifiers so each technique can be measured before it is trusted.

    Later chapters cover reinforcement learning with verifiable rewards through GRPO and distillation of reasoning behavior into smaller models. Manning published the 440-page book in June 2026. Readers new to LLM internals should finish Build a Large Language Model (From Scratch) first.

  7. Rank 07

    Python for Data Analysis

    Wes McKinney · 2012

    Wes McKinney created pandas, and his book remains the reference for the loading, cleaning, reshaping and group-by work that takes a large share of any machine learning project. It ranks seventh because fluency in vectorized NumPy and pandas operations pays off in nearly every other title here, from scikit-learn pipelines to the datasets used for LLM fine-tuning.

    The third edition is updated for pandas 2.0 and Python 3.10, and McKinney publishes it as an Open Access HTML edition with MIT-licensed code examples. Readers who work in Jupyter will find its step-by-step exploratory workflow directly usable.

  8. Rank 08

    Chip Huyen's earlier book covers the production machine learning that AI Engineering assumes: data pipelines, feature engineering, deployment, monitoring for distribution shift, continual learning and testing in production through shadow deployment, A/B tests and bandits. It ranks eighth because it explains engineering trade-offs that stay stable while tools change, which keeps it useful years after its 2022 release.

    Readers learn to judge models against business objectives rather than benchmark accuracy, and to decide when an organization should build shared ML platforms and when it should buy them. With more than 1,000 Amazon ratings, it has one of the largest reader bases in the group.

  9. Rank 09

    Aurélien Géron rebuilt his long-running machine learning course around PyTorch in 2025, and the result is one of the most complete single paths from classical methods to modern deep learning. Readers work through an end-to-end project, ensembles for tabular data, PyTorch autograd and explicit training loops, and then CNNs, RNNs, transformers and diffusion models.

    Later chapters show how LoRA, gradient accumulation and activation checkpointing make large pretrained transformers adaptable on modest hardware. The notebooks and exercise solutions are in a public GitHub repository. Readers choosing between Géron's two editions should pick this one unless their team standardizes on TensorFlow.

  10. Rank 10

    Designing Data-Intensive Applications

    Martin Kleppmann, Chris Riccomini · 2017

    Martin Kleppmann explains what happens inside the databases, logs and stream processors on which every AI system depends, and the book ranks tenth for engineers who build or operate the data platforms beneath models. Readers learn how log-structured and B-tree storage engines differ, why replication and partitioning create consistency anomalies, and how an immutable event log with derived views keeps many systems consistent.

    O'Reilly published the second edition, co-written with Chris Riccomini, in 2026. According to coverage of the revision, it adds material on cloud object storage and on AI workloads such as vector search and retrieval-augmented generation.

  11. Rank 11

    With more than 900 Amazon ratings at 4.7 stars, the TensorFlow edition of Aurélien Géron's course is one of the most reviewed books in the group. It shares the strengths of the PyTorch edition: a full end-to-end project, tree ensembles taught as tabular baselines, and practical chapters on initialization, batch normalization, optimizers, learning-rate schedules and dropout.

    It ranks below its successor because the field has largely moved to PyTorch. Teams committed to TensorFlow and Keras still get a complete course that runs from classical models through convolutional networks, transformers and diffusion models, and Géron keeps the third edition's code in a separate repository.

  12. Rank 12

    The Data Warehouse Toolkit

    Ralph Kimball, Margy Ross · 1996

    Ralph Kimball and Margy Ross wrote the standard method for designing the analytical tables that dashboards and machine learning pipelines read. Readers learn to declare the grain of every fact table first, to share conformed dimensions across business processes through an enterprise bus matrix, and to choose among slowly changing dimension types 0 through 7 when history matters.

    The third edition, published by Wiley in 2013, works through 12 case studies, each with a sample bus matrix. It ranks twelfth because ML teams that draw training data from a well-modeled warehouse inherit consistent definitions of customers, products and time.

  13. Rank 13

    R for Data Science

    Hadley Wickham, Garrett Grolemund · 2017

    R for Data Science is the only beginner-level book in the group and the most direct route into the tidyverse. Readers learn the tidy layout of one variable per column and one observation per row, layered ggplot2 visualization, the core dplyr verbs with grouping, and functions and iteration that cut copy-and-paste errors, finishing with Quarto documents that combine code, results and prose.

    The second edition, which adds Mine Çetinkaya-Rundel as co-author, is free online under a Creative Commons license. It gives R users the data-handling fluency that Python readers get from McKinney's book and prepares them for R-based statistical titles such as Statistical Rethinking.

  14. Rank 14

    Deep Learning for Coders with fastai and PyTorch

    Jeremy Howard, Sylvain Gugger · 2020

    Deep Learning

    Jeremy Howard and Sylvain Gugger teach deep learning top-down: readers train a working model first and study the theory behind it afterward. The approach suits programmers without heavy mathematics, and the book's emphasis on transfer learning shows how small teams reach strong accuracy with modest data and a single GPU.

    Its practical lessons on learning-rate finding, data augmentation and reading validation loss still apply, and the authors treat ethics directly, including feedback loops, bias and misuse. It ranks fourteenth because the fastai library calls in its examples have dated, even though the teaching method has not. Its notebooks are available on GitHub.

  15. Rank 15

    Trustworthy Online Controlled Experiments

    Ron Kohavi, Diane Tang, Ya Xu · 2020

    Ron Kohavi, Diane Tang and Ya Xu wrote the reference on measuring whether a product change, including a new model, helps users. Readers learn Twyman's law for treating surprising results as probable bugs, how to define an overall evaluation criterion tied to long-term value, and how sample ratio mismatch checks expose broken experiments before they mislead a team.

    Cambridge University Press published it in 2020, according to the book's site, and the authors draw on experimentation at Microsoft, Google and LinkedIn. It ranks fifteenth because an ML team that cannot test a launch online cannot tell whether a better offline model improved the product.

  16. Rank 16

    Vibe Coding

    Gene Kim, Steve Yegge · 2025

    Generative AI & LLMs

    Gene Kim, founder of Tripwire, and Steve Yegge, who spent nineteen years at Google and Amazon, apply long software careers to the problem of directing AI coding agents. The most useful chapters catalog how agents fail, including deleted tests, monolithic functions and destroyed work, and show how task decomposition, guardrails and inspection catch those failures before they reach production.

    Readers also get guidance on context management and on the standards and review practices organizations need. IT Revolution published it in October 2025. It ranks sixteenth as the only book in the group focused on working alongside coding agents rather than building AI systems.

  17. Rank 17

    Natural Language Processing with Transformers

    Lewis Tunstall, Leandro von Werra, Thomas Wolf · 2022

    Deep Learning

    Lewis Tunstall, Leandro von Werra and Thomas Wolf, three Hugging Face developers, teach transformer NLP through projects that mirror real work: text classification, multilingual named entity recognition, text generation, summarization and question answering. Readers also implement self-attention and the encoder and decoder blocks by hand, which makes the library's high-level calls easier to understand.

    The chapters on distillation, quantization and pruning remain useful for deployment, and the chapter on working with few or no labels helps teams short on annotations. It ranks seventeenth because the Transformers library has changed since 2022, and the authors' notebook repository notes that some code paths are no longer maintained.

  18. Rank 18

    Statistical Rethinking

    Richard McElreath · 2015

    Machine Learning

    Richard McElreath teaches Bayesian data analysis as scientific reasoning, giving ML engineers the causal thinking that prediction-focused texts omit. Readers learn to draw causal diagrams before choosing controls, to use multilevel models as a default for clustered data, and to manage overfitting with regularizing priors, information criteria and cross-validation.

    The second edition comes from CRC Press, with R code and community translations to PyMC, NumPyro and Pyro listed on McElreath's book page alongside his recorded lectures. Its 4.8-star Amazon average ties for the highest in the group; it ranks eighteenth because it serves a narrower audience than the machine learning courses ranked higher.

  19. Rank 19

    LLM Engineer's Handbook

    Paul Iusztin, Maxime Labonne · 2024

    Generative AI & LLMs

    Paul Iusztin and Maxime Labonne walk through one complete production LLM system, which they call the LLM Twin, from data collection to deployment. Readers separate feature, training and inference pipelines, combine retrieval-augmented generation with supervised fine-tuning and preference alignment, and add evaluation, inference optimization, monitoring and CI/CD.

    The code repository runs on ZenML, Qdrant, MongoDB and AWS SageMaker, which gives readers a realistic production stack that will date as tools change. It ranks nineteenth as the fullest end-to-end build in the group, suited to engineers prepared to swap components as the tooling evolves.

  20. Rank 20

    The Hundred-Page Language Models Book

    Andriy Burkov · 2025

    Generative AI & LLMs

    Andriy Burkov compresses the mechanics of language modeling into a short book that moves from count-based models through recurrent networks to transformers and finetuned LLMs. Readers see how next-token prediction connects every stage, how byte-pair encoding and embeddings shape what a model learns, and how instruction finetuning and low-rank adaptation adapt a pretrained model without full retraining.

    Burkov publishes it on a read-first, buy-later basis, with PyTorch implementations and Jupyter notebooks for each topic. It ranks twentieth because it covers much of the ground of Raschka's full build in far fewer pages, with correspondingly less depth.

  21. Rank 21

    Python Data Science Handbook

    Jake VanderPlas · 2016

    Jake VanderPlas covers the four tools at the center of Python data work, NumPy, pandas, Matplotlib and Scikit-Learn, with explanations clear enough for classroom use. Readers learn vectorization and broadcasting; pandas indexing, grouping, merging and pivoting; Scikit-Learn's consistent estimator interface; and the validation and learning curves that make the bias-variance trade-off visible.

    The full text is free online under a Creative Commons license, with MIT-licensed code. It ranks twenty-first because it overlaps McKinney's book on pandas, though it goes further into Scikit-Learn and model validation.

  22. Rank 22

    Fundamentals of Data Engineering

    Joe Reis, Matt Housley · 2022

    Joe Reis and Matt Housley describe data engineering as a lifecycle of generation, storage, ingestion, transformation and serving, with security, data management, DataOps, architecture, orchestration and software engineering running beneath every stage. The approach is deliberately tool-agnostic, so the book stays useful as specific products rise and fall.

    Readers get criteria for choosing technology by total cost, team capability and interoperability, and a case for loosely coupled, reversible designs. It ranks twenty-second as a clear map of the data platform work on which AI systems depend, backed by more than 900 Amazon ratings at 4.7 stars.

  23. Rank 23

    Machine Learning Design Patterns

    Valliappa Lakshmanan, Sara Robinson, Michael Munn · 2020

    Valliappa Lakshmanan, Sara Robinson and Michael Munn catalog thirty recurring solutions to machine learning problems, each named so practitioners can match a fix to a specific failure. Readers learn to reframe problems, to keep preprocessing with the model through the Transform pattern so training and serving compute features identically, to make training repeatable with checkpoints and distribution strategies, and to manage deployed models with continuous evaluation, feature stores and versioning.

    It ranks twenty-third because its patterns rest on principles rather than on any single library, and it suits readers who already train models and now need to ship them.

  24. Rank 24

    Dive into Deep Learning

    Aston Zhang, Zachary C. Lipton, Mu Li, Alexander J. Smola · 2023

    Deep Learning

    Dive into Deep Learning pairs mathematics, prose and runnable code on nearly every page, and its authors implement each model from scratch before reimplementing it with a framework's concise APIs. Coverage runs from linear networks through modern convolutional designs such as ResNet to attention mechanisms and transformers.

    The book is open source, with free PDF and notebook downloads at d2l.ai, code in PyTorch, JAX, TensorFlow and MXNet, and adoption at 500 universities in 70 countries. It ranks twenty-fourth because its textbook pace suits students and instructors more than engineers who want a faster path to applied work.

  25. Rank 25

    Machine Learning with PyTorch and Scikit-Learn

    Sebastian Raschka, Yuxi (Hayden) Liu, Vahid Mirjalili · 2022

    Sebastian Raschka, Yuxi (Hayden) Liu and Vahid Mirjalili wrote one of the most thorough practitioner courses in Python machine learning. Readers implement a neural network and backpropagation in plain NumPy before moving to PyTorch, then work through preprocessing, cross-validation, learning curves, randomized hyperparameter search, gradient boosting with XGBoost, and deep networks for images, text and graphs.

    It ranks twenty-fifth because Géron's PyTorch edition covers similar ground more recently. Readers who want the theory behind each algorithm explained alongside the code may still prefer it, and those planning to read Raschka's LLM books will find his notation familiar.

  26. Rank 26

    Generative AI Design Patterns

    Valliappa Lakshmanan, Hannes Hapke · 2025

    Generative AI & LLMs

    Valliappa Lakshmanan and Hannes Hapke apply the design-pattern format to LLM applications, cataloging 32 patterns with working code. Readers learn to treat hallucination, nondeterminism and knowledge cutoffs as engineering constraints, to use logits masking or formal grammars so downstream code can parse model output, and to improve retrieval through indexing, chunking and post-processing.

    Its patterns for agents add evaluation, reflection and guardrails for systems that face real users. It ranks twenty-sixth because it has far fewer reader ratings than older titles, but advanced engineers can apply its patterns directly to production code.

  27. Rank 27

    Maxim Lapan's book is the only dedicated reinforcement learning title in the group, implemented in PyTorch from the cross-entropy method through deep Q-networks, policy gradients and actor-critic methods. Readers see how double DQN, dueling networks and prioritized replay each fix a specific failure mode, and why A2C, PPO and SAC handle continuous action spaces better than value-based methods.

    The 2024 edition adds reinforcement learning from human feedback and MuZero, linking the material to the way modern language models are fine-tuned. It ranks twenty-seventh because reinforcement learning is a specialty, but it is the place to start for developers who want to implement RL algorithms themselves.

  28. Rank 28

    Hands-On Generative AI with Transformers and Diffusion Models

    Omar Sanseviero, Pedro Cuenca, Apolinário Passos, Jonathan Whitaker · 2024

    Generative AI & LLMs

    Omar Sanseviero, Pedro Cuenca, Apolinário Passos and Jonathan Whitaker explain both major families of open generative models, transformers for text and diffusion models for images, through shared building blocks such as tokenization, embeddings and attention. Readers learn how diffusion reverses a gradual noising process, how text prompts condition image output, and when LoRA fine-tuning repays the effort.

    The book also shows how to combine text encoders, latent autoencoders and noise schedulers into new applications without training from scratch. It ranks twenty-eighth because it has few reader ratings so far, though it is a strong choice for readers who want image generation covered alongside text.

  29. Rank 29

    Introduction to Machine Learning with Python

    Andreas C. Müller, Sarah Guido · 2016

    Andreas Müller, a core developer and co-maintainer of scikit-learn, wrote this workflow-first introduction with Sarah Guido, leaving mathematical derivations to other books. Readers learn how scaling, encoding and feature engineering affect results, why cross-validation and grid search belong inside a pipeline to prevent leakage, and which metrics to trust when classes are imbalanced.

    Each common algorithm comes with its strengths, key parameters and failure modes. It ranks twenty-ninth because Géron and Raschka cover the same ground and continue into deep learning, but readers who only need classical machine learning on tabular data will finish this book sooner.

  30. Rank 30

    Josh Starmer, whose StatQuest videos explain statistics and machine learning, uses step-by-step illustrations to make each neural network calculation visible. Readers see backpropagation as the chain rule applied repeatedly, word embeddings as learned numbers, attention as the fix for the encoder-decoder memory bottleneck, and the difference between decoder-only and encoder-only transformers.

    PyTorch code reinforces each idea. It ranks thirtieth because it covers less ground than the full textbooks, but it is the gentlest route into transformers for students and career-switchers who find equations intimidating.

  31. Rank 31

    Practical Statistics for Data Scientists

    Peter Bruce, Andrew Bruce, Peter Gedeck · 2017

    Machine Learning

    Peter Bruce, Andrew Bruce and Peter Gedeck wrote a compact statistics reference for data scientists who learned to code before they learned inference. Readers get exploratory data analysis, sampling and selection bias, the bootstrap and permutation tests, and the diagnostics and cross-validation needed to judge regression and classification models, with code in R and Python.

    The authors also identify which classical methods matter less in data science practice, which saves readers study time. More than 1,000 Amazon ratings make it one of the most widely read titles in the group, and it suits practitioners who need statistics in working form rather than as a course.

  32. Rank 32

    Data Science from Scratch

    Joel Grus · 2015

    Joel Grus implements the core algorithms of data science in plain Python, so readers see every assumption that a library call would hide. The book builds the linear algebra, statistics, probability and gradient descent beneath later models, then constructs k-nearest neighbors, naive Bayes, regression, decision trees, clustering and a neural network from simple, testable parts.

    It also treats getting and cleaning data as real work deserving care. It ranks thirty-second because its from-scratch code is slow by design and newer titles cover deep learning in more depth, but programmers who learn by building will understand the fundamentals better for having written them.

  33. Rank 33

    Generative Deep Learning

    David Foster · 2019

    Deep Learning

    David Foster surveys the major families of generative model, including variational autoencoders, GANs, autoregressive models, normalizing flows, energy-based models, diffusion models and transformers, and explains how each trades sample quality against speed and tractable likelihood. Readers build each family in Keras and see how diffusion underpins modern text-to-image systems.

    It ranks thirty-third because its Keras code suits fewer readers than PyTorch-based alternatives, but no other title in the group covers generative architectures as broadly, and the transformer material extends to music and multimodal generation.

  34. Rank 34

    Agentic Design Patterns

    Antonio Gullí · 2025

    Generative AI & LLMs

    Antonio Gullí catalogs 21 patterns for LLM agents, among them prompt chaining, routing, parallelization, reflection, exception handling, human-in-the-loop checkpoints, guardrails and evaluation. Readers get a structured vocabulary for designing agent systems, along with coverage of the Model Context Protocol and the Agent2Agent protocol, which let agents share tools and coordinate across frameworks and vendors.

    It ranks thirty-fourth because its framework-specific examples will need updating as agent libraries change. Architects can still use the catalog to break complex agent behavior into parts that are easier to design and debug.

  35. Rank 35

    Statistics, Data Mining, and Machine Learning in Astronomy

    Željko Ivezić, Andrew J. Connolly, Jacob T. VanderPlas, Alexander Gray · 2014

    Machine Learning

    Željko Ivezić, Andrew Connolly, Jacob VanderPlas and Alexander Gray wrote the graduate reference for applying statistics and machine learning to sky surveys. Readers learn Bayesian treatment of measurement error and selection effects, how to choose algorithms for catalogs of millions of objects, dimensionality reduction for high-dimensional spectra, and periodograms for irregularly sampled light curves.

    Figures are reproducible with the open-source astroML Python package, and Princeton University Press released a second edition in December 2019 with new sections on deep learning, hierarchical Bayes and approximate Bayesian computation. It ranks thirty-fifth because its audience is specialized, though its methods transfer to any field with noisy observational data.

  36. Rank 36

    Data Mesh

    Zhamak Dehghani · 2022

    AI Strategy & Leadership

    Zhamak Dehghani introduced data mesh in a 2019 article on Martin Fowler's site, written while she was a consultant at Thoughtworks, and this book develops the idea in full. Readers learn why central data teams become bottlenecks, how domain teams can own data as products with named owners, consumers and quality levels, and how a self-serve platform and federated computational governance keep those products interoperable.

    It ranks thirty-sixth because it says more about principles and organizational design than about implementation. Leaders deciding who should own analytical data in a large organization will find the argument laid out clearly.

  37. Rank 37

    Building Applications with AI Agents

    Michael Albada · 2025

    Generative AI & LLMs

    Michael Albada writes for engineers building a first agent or multiagent system, starting from principles rather than any single framework. Readers learn to treat agency as a spectrum in which more guardrails mean less autonomy, to design tools as the agent's means of acting, to separate retrieval of outside facts from memory of the agent's own history, and to defend against prompt injection and memory poisoning.

    It ranks thirty-seventh because it has fewer reader ratings than older titles and introduces topics more than it deepens them. Engineers new to agentic software get a sound conceptual base before moving to the pattern catalogs ranked higher.

  38. Rank 38

    Causal Inference

    Scott Cunningham · 2021

    Machine Learning

    Scott Cunningham teaches the research designs that applied economists use to estimate causal effects from observational data: directed acyclic graphs, potential outcomes, regression discontinuity, instrumental variables and difference-in-differences. Its strongest material addresses the bias that conventional two-way fixed-effects estimates carry when treatment begins at different times for different groups.

    Cunningham is revising it as Causal Inference: The Remix, whose online version includes code in R and Stata. It ranks thirty-eighth because prediction-focused data scientists need it less often, but anyone asked whether a model or product change caused an outcome needs these methods.

  39. Rank 39

    Machine Learning System Design Interview

    Ali Aminian, Alex Xu · 2023

    Ali Aminian and Alex Xu built their book around ten worked case studies, including visual search, YouTube video search, harmful content detection, video and event recommendation, ad click prediction and a personalized news feed, according to ByteByteGo's contents page. Each design starts by clarifying business objectives, constraints and scale before any model is chosen.

    It ranks thirty-ninth because its interview focus narrows the audience, but its explanations of two-stage candidate generation and ranking, offline and online metrics, and drift monitoring make it a compact primer on production recommendation and search systems.

  40. Rank 40

    Principles of Building AI Agents

    Sam Bhagwat · 2025

    Generative AI & LLMs

    Sam Bhagwat, CEO of the agent framework company Mastra, wrote a short orientation to agent building blocks. Readers learn to place a project on the spectrum from decision trees to autonomous planners, to sketch tasks as flowcharts before coding, to use structured workflows with branching, suspend-and-resume and streaming, and to add evals and tracing from the start.

    Mastra offers the third edition free in exchange for an email address. It ranks fortieth because it orients more than it teaches, but engineers starting a first agent project can read it quickly and then move to the pattern catalogs ranked higher.

How we ranked these books

Books are ranked on a weighted composite of six signals: reach, measured through Amazon rating volume and sales rank; critical consensus across independent best-of lists; awards; reader ratings; author authority; and editorial scoring. Editorial scoring for hands-on titles weighs the clarity of explanations, the quality and currency of the code, and how well the concepts hold up as libraries change. AI Engineering ranks first because it pairs the largest reader base in the group, more than 1,000 Amazon ratings at an average of 4.6 stars, with the most systematic treatment of evaluation, retrieval, finetuning and inference cost available to teams building on foundation models.

Read the full methodology

Questions

What is the best hands-on AI programming book in 2026?
AI Engineering by Chip Huyen ranks first. It covers the full process of building applications on foundation models, including evaluation, prompt engineering, retrieval-augmented generation and agents, finetuning, dataset engineering and inference optimization, and its two evaluation chapters are the strongest treatment of that subject in the group. It suits software engineers, ML engineers and technical product managers. Readers who want to understand model internals rather than ship products should start with Sebastian Raschka's Build a Large Language Model (From Scratch), which ranks second.
Which book teaches you to build a large language model from scratch?
Build a Large Language Model (From Scratch) by Sebastian Raschka has readers write a GPT-style model in PyTorch, covering tokenization, self-attention with causal masking, pretraining, loading GPT-2 weights, and fine-tuning for classification and instruction following. Manning states that the model runs on any modern laptop. The Hundred-Page Language Models Book by Andriy Burkov covers similar mechanics in fewer pages. Readers who finish Raschka's book can continue with his Build a Reasoning Model (From Scratch), which implements inference-time scaling, GRPO training and distillation.
Should I learn PyTorch or TensorFlow for AI programming?
Most of the newer books in the group use PyTorch, including Raschka's from-scratch titles, Aurélien Géron's 2025 Hands-On Machine Learning with Scikit-Learn and PyTorch, and Maxim Lapan's Deep Reinforcement Learning Hands-On. Readers starting now should learn PyTorch first unless their employer standardizes on TensorFlow, in which case Géron's earlier TensorFlow edition remains a complete course. Keras 3 offers a middle path: Deep Learning with Python shows the same model code running on TensorFlow, PyTorch or JAX.
Which hands-on AI books are free to read online?
Several authors publish full online editions. R for Data Science (second edition), Python for Data Analysis (third edition), Python Data Science Handbook, Dive into Deep Learning and the third edition of Deep Learning with Python can all be read free on their official sites. PDFs of An Introduction to Statistical Learning are available from statlearning.com, The Hundred-Page Language Models Book follows a read-first, buy-later model, and Mastra gives away Principles of Building AI Agents in exchange for an email address.
Do I need advanced math to learn AI programming?
Not to start. Code-first books such as Deep Learning for Coders with fastai and PyTorch, Introduction to Machine Learning with Python and The StatQuest Illustrated Guide to Neural Networks and AI teach working skills with limited mathematics. Comfort with linear algebra, probability and calculus becomes necessary for deeper titles such as Dive into Deep Learning, Build a Reasoning Model (From Scratch) and Statistics, Data Mining, and Machine Learning in Astronomy. An Introduction to Statistical Learning and Practical Statistics for Data Scientists build statistical intuition without proofs.
What are the best books for building AI agents?
Generative AI Design Patterns by Valliappa Lakshmanan and Hannes Hapke and Agentic Design Patterns by Antonio Gullí catalog reusable designs for retrieval, reflection, guardrails, evaluation and agent coordination. Building Applications with AI Agents by Michael Albada gives a principles-first introduction that includes security risks such as prompt injection, and Principles of Building AI Agents by Sam Bhagwat is a short, free orientation. AI Engineering also covers agents within its broader treatment of foundation-model applications. Developers who direct coding agents rather than build them should read Vibe Coding by Gene Kim and Steve Yegge.