Chapter 3: Classification

Will Toth
3 min readJun 12, 2021

--

A Review of Hands-On Machine Learning with Scikit-Learn, Keras & Tensorflow by Aurélien Géron

Classification

If you have ever wondered whether food is a hotdog, or not a hotdog, then boy do I have news for you! Classification is the process of using machine learning to sort data into different groupings. Different uses of classification include autonomous vehicles deciding whether or not an object on the side of the road is a tree or a human or whether an image is a cat or a dog. These classifications can make binary decisions like whether an object is a hotdog or not a hotdog, or can classify objects into many categories like whether an object is a hotdog, a piece of pizza, a sandwich, or an apple.

Evaluating Classification

Similar to the first 3 chapters of Hands on Machine Learning Géron chooses to focus on the evaluation of classifiers rather than on the algorithms themselves. Some methods introduced in this chapter are Precision vs. Recall and ROC curves, including it’s area under the curve score (AUC).

Major Takeaways

Precision and Recall

These two evaluation metrics have an inverse relationship. This is due to the focus of precision on false positives and recall on false negatives. In more simple terms precision is the percent of “true” values that are in fact false. Recall on the other hand is the percent of “false” values that are actually true.

One v. One and One v. Rest

These are the two ways to train Classifiers that are introduced in this chapter. I was actually surprised to find out that Sklearn classifiers use one or the other under the hood and if you don’t examine your results you will likely not know which one is used.

A One v. One classifier essentially just trains every pair of classifiers in your set directly against each other. So, you end up getting a time complexity of approximately (n(n-1))/2 due to the number of matchups. These algorithms calculate who is likely going to win each match up and then decides the winner based on whatever value wins the most match ups.

One v. Rest is exactly what is sounds like, training your values against the rest of the values. This gets trained in n time so it definitely takes less time to train than ovo. When it comes to evaluating values it simply just picks whatever value has the highest probability compared to the rest. This one seems simpler and faster but there is a reason that ovo models are still used today.

My Thoughts

My example of hotdog vs not hotdog is a reference to the HBO show Silicon Valley. In the show one of the characters creates an app called “See Food” which is the Shazam for food. But due to time restraints (among other issues) he only trains it on hotdogs, resulting in the app becoming a one v. rest where hotdogs are the only foods that are classifiable. This was a shockingly effective way for me to keep up with what I was reading when learning about classifiers. You can also download it for iOS and Android. You can also watch the original clip here.

p.s. Now is a good time to brush up on linear algebra and partial derivatives as chapter 4 introduces the first signs of somewhat rigorous math.

Thanks for reading!

If you have any questions or feedback please reach out to me on twitter @wtothdev or leave a comment!

Additionally, I wanted to give a huge thanks to Aurélien Géron for writing such an excellent book. You can purchase said book here (non-affiliate).

Disclaimer: I don’t make any money from any of the services referenced and chose to read and review this book under my own free will.

--

--

No responses yet