Pattern Recognition
This playlist is my study notebook from the Pattern Recognition course I took, taught by Dr. Francisco Boldt. The guy is excellent, he genuinely codes the models by hand, live, in class, no pre-baked formula slides, and he's teaching me neural networks now too. If you landed here coming from one of his classes, you already know what I mean.
Unlike the Andrew Ng specialization playlist, the lecture notebooks here are a lot leaner: barely any markdown cells, it's the professor live-coding and everyone following along. So the work of digging into the "why" behind each line of code is heavier here, and for that I lean on Pattern Recognition and Machine Learning, by Christopher Bishop (2006), pretty much a bible in the field, as the theoretical reference.
The notebooks come from the course repository, pablobelmiro/aulasml, a fork of Dr. Boldt's own repository, where he publishes each lecture's code. In this playlist's posts, whoever "wrote" the code is always him, the professor; the foundational explanation, with the metaphor, the slightly-off analogy, and the buddy-sitting-next-to-you tone, that part is mine.
Every lecture becomes a post here. We start at the start: the same linear regression problem from the other playlist, except this time the code is being written live on the whiteboard.
Playlists · 15 posts
- Linear Regression by Hand: Building My Own Estimator
Lecture one of my Pattern Recognition course: the professor grabs a real diabetes dataset, hand-picks coefficients, and builds an estimator following scikit-learn's own API. I retell the why behind each step, with Bishop's book alongside.
- The Normal Equation: Solving Regression in One Shot
Lectures 2b and 2c: instead of iterating gradient descent, the professor solves linear regression with a single closed-form computation using the pseudo-inverse, matches scikit-learn's LinearRegression exactly, and compares it against five other kinds of regressor. I explain the why behind each step.
- Classification by Threshold: When Regression Becomes a Decision
Lectures 3a and 3b: the professor reuses the exact same linear regression class to classify breast cancer, shows why a threshold was missing, and then normalizes the data for a reason unlike anything I'd seen before.
- KNN: Classifying by Looking at Your Neighbors
Lecture 4a: the professor implements K-nearest-neighbors by hand, matches scikit-learn's KNeighborsClassifier exactly, and shows K isn't 'the bigger the better.' I explain why K is a smoothing parameter.
- Pipeline, Cross-Validation, and GridSearch: the Real Workflow
Lectures 4b, 4c, and 4d: the professor builds the real professional workflow on top of KNN, and along the way I find an actual bug in his code, a return sitting inside the wrong loop.
- Decision Trees: Yes-or-No Questions Until Only One Answer Is Left
Lectures 5 and 5b: the professor builds a greedy decision tree from scratch, guided by Gini impurity, first on categorical attributes, then on continuous ones. I explain why limiting depth doesn't always help.
- Ensembles: the Wisdom of Crowds (and Its Limits)
Lecture 6: the professor combines several weak classifiers on real faces and reaches 96%, but the ending is a lesson in humility: a single simple model beats every ensemble tried, even the fanciest one.
- The Titanic: My First Genuinely Messy Dataset
Lecture 7: the professor builds a full preprocessing pipeline on the classic Titanic dataset, missing data and all, and shows the same train-set-accuracy mistake I'd already seen before, except this time with a real consequence.
- K-means: When Clustering Becomes a Feature Engineering Trick
Lecture 8: the professor enters unsupervised learning with K-means built by hand, the elbow method for picking K, and a trick I didn't see coming: using the discovered groups as new features for a supervised classifier.
- DBSCAN and Semi-Supervised Learning: When Clustering Helps You Label
Lecture 9: the professor shows where K-means fails badly, introduces DBSCAN as a density-based alternative, then uses clustering to pick which examples to label better when labels are expensive.
- PCA: Reducing Dimensions Without Losing What Matters (Not Always)
Lecture 10: the professor uses PCA to compress real data without losing much accuracy, but closes with an important warning: PCA only looks at variance, not at the label, and sometimes throws away exactly the information you needed.
- Gaussian Mixtures and Anomaly Detection: Clustering With Shape
Lecture 11: the professor swaps K-means for Gaussian mixtures when groups aren't round, uses density to spot anomalies, then compares three different anomaly detectors, all needing careful tuning to work well.
- Fraud Detection: When 99.8% Accuracy Means Nothing
Lecture 12: the professor uses Kaggle's real credit card fraud dataset (492 frauds in nearly 285 thousand transactions) to show why accuracy lies on imbalanced data, and a data leak so subtle the wrong result looks great.
- Feature Selection: Letting the Label Choose, Not Just Variance
Lecture 13: the professor builds a ruler from scratch to rank which MNIST pixels actually help tell one digit from another, and shows that dropping 77% of the variables barely costs any accuracy.
- Text Becomes a Vector: My First Steps in NLP
Lecture 14, the last one in the course: the professor turns a movie review into numbers by hand, and shows a homemade TF-IDF matching scikit-learn's official TfidfVectorizer.