Ben Dickson is the founder of TechTalks. He writes regularly about business, technology and politics. Follow him on Twitter and Facebook Ben Dickson is the founder of TechTalks. He writes regularly about business, technology and politics. Follow him on Twitter and Facebook
Teaching yourself Python machine learning can be a daunting task if you don’t know where to start. Fortunately, there are plenty of good introductory books and online courses that teach you the basics.
It is the advanced books, however, that teach you the skills you need to decide which algorithm better solves a problem and which direction to take when tuning hyperparameters.
A while ago, I was introduced to Machine Learning Algorithms, Second Edition by Giuseppe Bonaccorso, a book that almost falls into the latter category.
While the title sounds like another introductory book on machine learning algorithms, the content is anything but. Machine Learning Algorithms goes to places that beginner guides don’t take you, and if you have the math and programming skills, it can be a great guide to deepen your knowledge of machine learning with Python.
Oiling your machine learning engine
Machine Learning Algorithm kicks off with a quick tour of the fundamentals. I really liked the accessible definitions Bonaccorso uses to explain key concepts such as supervised, unsupervised, and semi-supervised learning and reinforcement learning.
Bonaccorso also draws great analogies between machine learning and descriptive, predictive, and prescriptive analytics. The machine learning overview also contains some hidden gems, including an introduction to computational neuroscience and some very good precautions on the pitfalls of big data and machine learning.
That said, the machine learning overview does not go into too much details and would be hard to understand for novices. Given the audience of the book, it serves to refresh and solidify your understanding of machine learning, not to teach you the basics.
Next, Machine Learning Algorithms builds up on that brief overview and goes into more advanced concepts, such as loss functions, data generation processes, independent and identically distributed variables, underfitting and overfitting, different classification strategies (one-vs-one and one-vs-all), and elements of information theory. Again, the definitions are smooth and very accessible for someone who has already had hands-on experience with machine learning algorithms and linear algebra.
Before going into the exploration of different algorithms, the book covers some more key concepts such as feature engineering and data preparation. Here, you’ll get to revisit some of the key classes and functions of scikit-learn, the main Python machine learning library. If you already have a solid knowledge of Python and numpy, you’ll find this part a pleasant review of one-hot encoding, train-test splitting, imputing, normalization, and more. There is some very great stuff in the third chapter, including one of the best and most accessible definitions of principle component analysis (PCA) and feature dependence in machine learning algorithms. You’ll also get to see some of the more advanced techniques not covered in introductory books, such as non-negative matrix factorization (NNMF) and SparsePCA. Of course, without the background in Python machine learning, these additions will be of little use to you.
The real meat ofthe book starts in the fourth chapter, where you get to the machine learning algorithms. Here, I had mixed feelings.
A rich roster of machine learning algorithms
In general, Machine Learning Algorithms is nicely structured and stands up to the name. There are chapters on regression, classification, support vector machines (SVM), decision trees, and clustering. The book follows up with a few chapters on recommendation systems and natural language processing applications, and finishes off with a very brief overview of deep learning and artificial neural networks.
The main chapters offer in-depth coverage of principle machine learning algorithms in Python, including details not covered in introductory books. For instance, the regression chapter goes into an extensive coverage of outliers and methods to mitigate their effects. The classification chapter has a nice discussion on passive-aggressive classification and regression in online algorithms. The SVM chapter has a comprehensive (but complicated) discussion on semi-supervised vector machines. And the decision trees chapter provides a good coverage of the specific sensitivities of DTs such as class imbalance, and some practical tips on tweaking trees for maximum performance.
The clustering section really shines. It spans across three full chapters, starting with fundamentals (k-nearest neighbors and k-means) and goes through more advanced clustering (DBSCAN, BIRCH, and bi-clustering) and visualization techniques (dendrograms). You’ll also get a full account of measuring the effectiveness of the results and determining whether your algorithm has latched onto the right number and distribution of clusters.
Across the book, there are thorough discussions of the mathematical formulas behind each machine learning algorithm. You need to come strapped with solid linear algebra and differential and integral calculus fundamentals to fully understand this (if you need to hone your machine learning math skills, I’ve offered some guidance in a previous post).
The book also makes extensive use of functions numpy, scipy, and matplotlib libraries without explaining them, so you’ll need to know those too (you can find some good sources on those libraries here).
One of the most enjoyable things about Machine Learning Algorithms are the chapter summaries. After going through the nitty-gritty of the math and Python coding of each machine learning algorithm, Bonaccorso gives a brief review of where to apply each of the techniques presented in the book. There are also many references to relevant papers that provide more in-depth coverage of the topics discussed in the book. It’s refreshing to see some of the old but fundamental papers from early 2000s being mentioned in the book. Those things tend to get buried under the hype surrounding state-of-the-art research.
Machine Learning Algorithms finishes off with a good wrap-up of the machine learning pipeline and some key tips on choosing between the different Python tools introduced across the book.
Not enough real-world examples
The one thing, in my opinion, that should set a book on Python machine learning apart from research papers and theoretical textbooks are the examples. A good book should be rich in use-case oriented examples that take you through real-world applications and possibly build up through the book.
Unfortunately, in this respect, Machine Learning Algorithms leaves a bit to desire.
For one thing, the examples in the book are mostly generic, using data-generation functions in scikit-learn such as make_blobs, make_circles, and make_classification. Those are good functions to show certain aspects of Python machine learning, but not enough to give you an idea of how to use the techniques in real life, where you have to deal with noise, outliers, bad data, and features that need to be normalized and categorized.
The code is in plain Python scripts as opposed to the preferred Jupyter Notebook format (which is not much of a big deal, to be fair). Also, while the book omits much of the sample code and focuses on the important parts for the sake of brevity, it made it hard to navigate the sample files at times.
The book does cover some real-world examples, including one with airfoil data in the SVM chapter and another with the Reuters corpus in the NLP chapter. The recommendation systems chapter also includes a few decent use cases, but that’s about it. Without concrete examples, the book often reads like a disparate reference manual with code snippets, which makes it even more crucial to have solid experience with Python machine learning before picking this one up.
Another thing that didn’t really appeal to me were the two chapters on deep learning. Machine Learning Algorithms provides a good overview of deep learning and discusses convolutional neural networks, recurrent neural networks, and other key architectures. But the problem is that introductory books on Python machine learning already cover these concepts and much more. So most of the people who make it this far through the book without putting it down won’t find anything new here (aside from the mention of KerasClassifier maybe).
Midway through Python machine learning journey
So, where does this book stand in the roadmap to learning machine learning with Python? It’s neither beginner level, nor super-advanced. I would suggest picking up Machine Learning Algorithms after you read an introductory-to-intermediate book like Python Machine Learning or Hands-on Machine Learning, or an online course like Udemy’s “Machine Learning A-Z.” Otherwise, you won’t be able to make the best of the rich content it has to offer.
Once you finish this one, you might want to consider Bonaccorso’s Mastering Machine Learning Algorithms, Second Edition, which expands on many of the topics presented in this book and takes them into even greater depth.
This article was originally published by Ben Dickson on TechTalks, a publication that examines trends in technology, how they affect the way we live and do business, and the problems they solve. But we also discuss the evil side of technology, the darker implications of new tech and what we need to look out for. You can read the original article here.
Get the TNW newsletter
Get the most important tech news in your inbox each week.