Skip to content

Machine Learning with PyTorch and Scikit-Learn: the rare class decides everything

Sebastian Raschka, Yuxi (Hayden) Liu and Vahid Mirjalili · Packt, 2022 (partial copy)
28 de abril de 2026 por
Machine Learning with PyTorch and Scikit-Learn: the rare class decides everything
Andrés Briñez

The complete book runs from the perceptron to transformers and reinforcement learning. The copy I have reaches model evaluation and ensembles, that is, the classical scikit-learn part. I say so up front because judging a book by its first third is an elegant form of making things up.

What I took from it

The chapter on evaluation and hyperparameter tuning is the most useful one for somebody who sells, and not because of the code. It explains why an accuracy figure can be a perfect lie when classes are imbalanced, which is the normal state of business data: fraud, default, returns and defects are rare by definition. With two per cent positives, a model that always says no is right ninety-eight per cent of the time and is worth nothing.

Out of it came a question I ask before promising anything over historical data: what proportion does the class of interest have. If nobody knows, the project starts there and not at the model. And the figure I commit to is not accuracy, it is how many real cases get caught and how many false alarms get raised, two numbers that move against each other.

The other idea I took is learning curves: they distinguish a model that never learned from one that memorised the data. It is the cheapest way to tell whether the problem is the model or the amount of data, and it saves weeks of trying variants.

What I left out

The entire second half, which I do not have. And the dimensionality reduction chapter, well explained but solving a problem that barely shows up when the data comes out of an ERP: there you do not have too many variables, you have too few, and the ones you have were captured badly.

# AI
A Spanish SQL certification manual, and the one chapter that earns it
Jesús Francisco Camuña Rodríguez · IC Editorial, 2025
WhatsApp