# models for hierarchal classification

Are there any classifiers that can do hierarchal classification? For example, we may have some text and want to predict it's class in an ontology (which is a tree). As a concrete example, let's say we have some text such as "iphone 7 case" and we want to learn it maps to the path [electronics -> smart-phones & accessories -> cases] in an ontology of products. See imagenet for an example of images with hierarchal label structure).

The common naive solution is to flatten the problem into a multi-class classification problem but this simplification has two issues that a model aware of hierarchy could address:

1. If a particular class is rare or even missing in the training data than a multi-class classifier does not have enough information to make a good prediction. A hierarchal classifier could utilize related examples that have a common ancestry with the rare class though.

2. A multi-class classifier's loss function does not give any credit if the predicted class is "almost right" (e.g. most of the path is correct but it may have predicted the child, a parent, or a sibling instead of the correct class). A hierarchal classifier's loss function could give partial credit if the path was mostly correct.

Does anyone know of any models that can do hierarchal classification?

There is a whole literature on the subject. The function hclust in R has a wide array of algorithms that do hierarchical clustering: Complete Linkage Analysis, and Ward's D2 minimiazation, Unweighted Pair Group Method with Arithmetic Mean (UPGMA), McQuitty's weighted PGMA, Weighted Pair Group Median Cluster (WPGMC) and Unweighted Pair Group Centroid Clustering (UPGMC, not sure why the M is there). These are discussed in Murtagh's 1985 text "Multidimensional Clustering Algorithms", a more modern reference is Legendre/Legendre's "Numerical Ecology". Freely available lecture notes are available here.Your concerns are inline with the overall rational for hierarchical clustering.