You Are Probably Building Inconsistent Classification Models Without Even Realizing
The limitations of always using cross-entropy loss.
Most multiclass classification neural networks are trained using the cross-entropy loss function:
However, it is not entirely suitable in certain situations.
More specifically, one of the biggest mistakes people make is that they don’t truly understand the inherent nature of their dataset.
To exemplify, in many real-world classification tasks, the class labels often possess a relative ordering between them (also called ordinal datasets):
Age group detection (child, teenager, young adult, middle-aged, and senior) is one such example, where labels possess an ordered relationship.
However, cross-entropy entirely ignores this notion.
Consequently, the model struggles to differentiate between adjacent labels, leading to suboptimal performance and classifier ranking inconsistencies.
By “ranking inconsistencies,” we mean those situations where the predicted probabilities assigned to adjacent labels do not align with their natural ordering.
For example, if the model predicts a lower probability for the
child age group than for the
teenager age group, despite the fact that
teenager logically follows
child in the age hierarchy, this would constitute a ranking inconsistency.
We could also interpret it in this way that, say, the true label for an input sample is
young adult. Then, in that case, we would want our classifier to highlight that the input sample is “at least a child,” “at least a teenager,” and “at least a young adult.”
However, since cross-entropy loss treats each age group as a separate category with no inherent order, the model struggles to learn and generalize the correct progression of age.
Ordinal datasets are quite prevalent in the industry, and typical classification models almost always produce suboptimal results in such cases.
With special attention and techniques, however, one can not only add more interpretability to ML models but also produce more accurate machine learning models.
What are these techniques?
If you are curious, then this is the topic of our most recent ML deep dive: You Are Probably Building Inconsistent Classification Models Without Even Realizing.
While cross-entropy is undoubtedly one of the most used loss functions for training multiclass classification models, it is not entirely suitable in certain situations.
Yet, many people stick to using cross-entropy, no matter what type of dataset they are dealing with.
Learning about the advanced framework we are discussing in the above article will help you make informed decisions in model building. We also implement the discussed idea for a thorough understanding.
I am sure you will learn something valuable today.
👉 Over to you: What are some other challenges with nominal classification models?
Thanks for reading Daily Dose of Data Science! Subscribe for free to learn something new and insightful about Python and Data Science every day. Also, get a Free Data Science PDF (550+ pages) with 320+ tips.
👉 If you liked this post, don’t forget to leave a like ❤️. It helps more people discover this newsletter on Substack and tells me that you appreciate reading these daily insights.
The button is located towards the bottom of this email.
Thanks for reading!