
Data science from scratch
Introduction
Nova: Welcome back to Aibrary, the show where we crack open the most influential books in tech and figure out what actually makes them worth your time. Today, we're diving into a book with a provocative subtitle: First Principles with Python. It's called Data Science from Scratch by Joel Grus, and here's a question to kick us off. What if I told you that the best way to learn data science isn't by mastering scikit-learn or TensorFlow first, but by writing every algorithm yourself in raw, vanilla Python, no shortcuts allowed?
Nova: That's the radical bet Joel Grus makes in this book, and it has resonated with tens of thousands of readers since the first edition dropped in 2015, followed by a thoroughly revamped second edition in 2019. This is an O'Reilly book that's been cited over 800 times in academic literature alone.
Nova: So let's talk about it. Grus was a software engineer at Google who later moved to the Allen Institute for Artificial Intelligence. He came from a math and economics background, and in his own words, he was a guy who believed you shouldn't use something until you could prove it. That ethos is baked into every page of Data Science from Scratch. The book takes you from basic Python all the way to neural networks and deep learning, and at every step, you're building the tools yourself, by hand. It's almost 400 pages in the second edition, spanning 27 chapters, and people have described it as the single most comprehensive one-stop resource for a beginner data scientist.
Nova: So whether you're an aspiring data scientist drowning in course options, or you've been in the field for a while and want to understand what's actually happening under the hood of your favorite libraries, this one's for you. Let's get into it.
Why You Should Reinvent Every Wheel
The From Scratch Philosophy
Nova: Let's start with the core premise because it's genuinely counterintuitive. The data science ecosystem today is dominated by incredibly polished libraries. You can import scikit-learn and build a random forest in five lines of code. You can pip install TensorFlow and have a deep learning model running in minutes. So why on earth would anyone spend their time implementing these things from scratch?
Nova: Grus's answer is rooted in his math background. He had a professor who once looked at a syllabus from the previous semester and said, oh good, you proved that theorem, that means I can use it in this class. That idea, that you shouldn't use things unless you truly understand them, is the philosophical backbone of the entire book.
Nova: And here's the thing. When you copy-paste five lines of scikit-learn code and get a working model, it's incredibly easy to have no idea what you just did. You might not understand why your linear regression is underfitting, or why your k-nearest neighbors classifier is struggling with high-dimensional data. Grus was bothered by the number of books that just told you what commands to type without ever explaining what was going on behind the scenes.
Nova: But isn't that going to produce really slow, impractical code? I mean, nobody's going to deploy a handwritten neural network to production when PyTorch exists. What's the actual value?
Nova: That's a fair pushback, and Grus is totally upfront about it. In the final chapter, he literally says, implementing things from scratch is great for understanding how they work, but it's generally not great for performance, ease of use, rapid prototyping, or error handling. The code in the book is deliberately instructional, not operational. He even makes a point of writing everything in pure Python rather than using NumPy, because he wants to lower the barrier to entry as much as possible.
Nova: One reviewer put it beautifully. They said the book gives you an intimate understanding of all the micro decisions involved in these algorithms. When you've written gradient descent from scratch, you actually feel the step sizes. You understand what happens when the learning rate is too high or too low because you've debugged it yourself.
Nova: And Grus is a stickler for clean, readable code. He told the Talk Python To Me podcast that he spent as much time revising the code examples as he did revising the prose. He'd go back over them again and again asking, can I make this simpler? Can I make this cleaner? The result is Python code that's genuinely pleasant to read, even if you're not an expert. He leans heavily on list comprehensions, generator expressions, defaultdict and Counter from collections. It's functional, Pythonic, and very intentional.
Nova: Plus, in the second edition he added type annotations throughout. That might sound like a small thing, but for someone learning, seeing def predict -> float gives you so much more context than a bare function signature. You immediately know what's going in and what's coming out.
Nova: So the philosophy is basically: understand the fundamentals so deeply that when you eventually pick up scikit-learn and PyTorch and all the real-world tools, you'll know exactly what they're doing, and more importantly, when they might be going wrong.
From Python Crash Course to Deep Learning
Inside the Book's Architecture
Nova: So let's actually walk through what this book covers, because the breadth is genuinely impressive. It opens with a chapter that's essentially a day in the life of a data scientist at a fictional company called DataSciencester, a social network for data scientists. This framing device runs through the entire book. You're hired as the lead data scientist, and each chapter introduces a new concept because your fictional manager comes to you with a new problem to solve.
Nova: I love that approach. It makes every algorithm feel earned. You're not learning logistic regression because it's Chapter 16, you're learning it because your boss wants to know which users are likely to pay for a premium account, and now you need a classification model.
Nova: Exactly. After the intro, you get a crash course in Python. Then three chapters on the mathematical foundations: linear algebra, statistics, and probability. Then gradient descent, which bridges the math and the machine learning. Then two practical chapters on getting data through web scraping and APIs and working with that data, including cleaning, scaling, and dimensionality reduction with PCA.
Nova: And then the machine learning chapters kick off. You get k-nearest neighbors, naive Bayes, simple and multiple linear regression, logistic regression, decision trees, neural networks, deep learning, and clustering. After the ML core, there are chapters on natural language processing, network analysis, recommender systems, databases and SQL, MapReduce, and in the second edition, a brand new chapter on data ethics. It ends with a chapter called Go Forth and Do Data Science, which points you to the real-world libraries you should use next.
Nova: That's a lot of ground to cover. I'm curious about the second edition specifically. The first edition used Python 2.7, and Grus actually wrote on his blog that he felt genuinely guilty about having a book out there telling people to use Python 2. What else changed?
Nova: A lot, actually. He described it as being on some level just an improved, more modern version, but the changes were significant. Beyond the Python 3.6 upgrade, he cleaned up all the code, saying he was a much better programmer four years later. He removed language features like map, filter, and partial that he had decided were best avoided. He added assert statements throughout for testing. He used Python 3.6 type annotations everywhere. He fixed broken examples. The original book had a scraping example for the O'Reilly store, which no longer existed, so he replaced it with scraping congress. gov.
Nova: But the two biggest additions were a full chapter on deep learning and the data ethics chapter. The deep learning chapter was based on a live-coding stunt he'd been doing where he'd build a deep learning library from scratch in an hour. He took that approach and expanded it into a proper chapter, building on it to modernize the NLP chapter with sections on word2vec and recurrent neural networks.
Nova: And the data ethics chapter, that feels particularly timely. What does he cover there?
Nova: It's a shorter chapter but a powerful one. He uses real examples to highlight that data ethics is complicated and far from settled. One of the most striking points he makes is about parole models. Your model might do a perfect job of predicting which released criminals get rearrested, but if those rearrests are themselves the result of biased real-world processes, then your model might simply be perpetuating that bias. It's a sharp reminder that even technically perfect models can encode and amplify existing injustices.
Nova: That's the kind of perspective that separates someone who can run model. fit from someone who actually thinks critically about what their model is doing in the world. It's great that he included it.
The Ideal Reader and the Honest Tradeoffs
Who Is This Book Actually For?
Nova: So let's get practical. If someone is listening right now and wondering whether they should pick up this book, how do they know if it's right for them?
Nova: The book is aimed at intermediate programmers who want to get into data science and machine learning. You don't strictly need Python experience because there's a crash course in Chapter 2, but honestly, having some comfort with Python will make the experience much smoother. The same goes for math. The book covers linear algebra, statistics, and probability from the ground up, but if you've seen a vector or a probability distribution before, you'll move faster.
Nova: What if someone is coming from R instead of Python?
Nova: Then this book probably isn't for them, and Grus is refreshingly candid about why. He's said publicly that R is not sympathetic with the way his brain works. There's a running joke that R is a language designed by statisticians for statisticians. Python, in contrast, is what he finds readable and teachable. The Python code in this book, when written well, is almost like reading pseudocode. You don't need to be an expert to understand what's happening.
Nova: That makes sense. And I've read reviews that describe the book as giving you breadth rather than depth. Is that fair?
Nova: That's exactly right, and Grus himself would agree. In his own words, it's got math but only as much as is totally necessary. Necessarily it doesn't go deep into any of these areas, but it establishes a broad, solid foundation. Think of it as a launching pad. Each chapter ends with recommendations for further reading so you know where to go next.
Nova: One review I read pointed out that the book doesn't always explain why certain topics matter. Like, you learn linear algebra, but the book doesn't spell out exactly how it underpins machine learning. You kind of figure it out as you go.
Nova: That's a fair critique. The book assumes a certain intellectual curiosity. It shows you the tools and the code, and it trusts you to connect the dots. For some learners, that's liberating. For others, it might feel like a gap. But the counter-argument is that there are plenty of resources that explain the why. What's rare is a resource that shows you the how, step by step, in clean, understandable code.
Nova: And I think the numbers speak for themselves. One reviewer logged about 25 hours going through the book and estimated it could take much longer if you were really running and tinkering with every code example. The GitHub repository for the book is active and well-maintained. It's been recommended by data science educators, used in university courses, and consistently appears on must-read lists alongside books like Python Data Science Handbook and Hands-On Machine Learning.
Nova: It's worth noting too that Grus is kind of a character in the data science community. He gave a famous talk at JupyterCon in 2018 called I Don't Like Notebooks that basically started what people now jokingly call the Notebook Wars. He has strong opinions and he's not afraid to share them. That personality comes through in the writing. It's a technical book, but it's not dry. It's got a light, sometimes humorous style, which makes it much more approachable than a typical textbook.
Conclusion
Nova: Alright, let's bring this home. We've covered a lot of ground today. Data Science from Scratch by Joel Grus is built on a simple but powerful idea: you understand things better when you build them yourself. It walks you through the entire data science pipeline, from Python basics through probability and statistics, through every major machine learning algorithm, all the way to deep learning and NLP, and it does it all in raw Python, no black boxes.
Nova: The second edition brought the book firmly into the modern era with Python 3.6, type annotations, cleaner code, and important new chapters on deep learning and data ethics. It's been cited over 800 times, translated into multiple languages, and it's widely considered one of the best entry points into data science for people with a programming background.
Nova: What I keep coming back to is this idea that the book doesn't just teach you data science, it teaches you intellectual confidence. When you've implemented backpropagation yourself, when you've written your own k-means clustering from scratch, you stop being intimidated by these algorithms. You see them for what they are: a set of clear, logical steps that any curious person can understand.
Nova: And the honesty of the approach is refreshing. Grus never pretends you're going to use this code in production. He explicitly tells you to go use scikit-learn and TensorFlow when you're done. The point isn't the code itself. The point is the understanding.
Nova: If I had to sum up the book in one sentence, it would be this: it's a book that respects your intelligence enough to show you how things really work, not just which buttons to press.
Nova: That's a great way to put it. And I think the final chapter title says it all: Go Forth and Do Data Science. The book is a beginning, not an ending. It's meant to give you the foundation you need to learn more, to build more, and to think more critically about the models you create and the data you use.
Nova: Thanks for listening to Aibrary. If today's episode sparked your curiosity, go check out Data Science from Scratch by Joel Grus. The code is all open source on GitHub, so you can literally start reading the examples right now for free. And if you do pick up the book, remember the most important lesson: don't just read the code. Type it out. Break it. Fix it. That's how the learning actually happens.
Nova: This is Aibrary. Congratulations on your growth!