Local Hierarchical Classifier
A local hierarchical classifier
is a supervised machine learning model, where the output of the classification algorithm is defined over a pre-established hierarchical class taxonomy. In HiClass, there are 3 main approaches for local hierarchical classification, i.e., the most common design patterns for local hierarchical classification identified in the literature 1, which are the Local Classifier Per Node, Local Classifier Per Parent Node and Local Classifier Per Level.
In this example, we will be using the LocalClassifierPerNode
along with the RandomForestClassifier
from scikit-learn, but you can click on the other tabs to see how the code changes for the LocalClassifierPerParentNode
and LocalClassifierPerLevel
:
from hiclass import LocalClassifierPerNode
from sklearn.ensemble import RandomForestClassifier
from hiclass import LocalClassifierPerParentNode
from sklearn.ensemble import RandomForestClassifier
from hiclass import LocalClassifierPerLevel
from sklearn.ensemble import RandomForestClassifier
We will be using a RandomForestClassifier
for each node in the LocalClassifierPerNode
, except for the root node. This LocalClassifierPerNode
model will have the same structure pre-defined in the hierarchical data used to train the model. This is how we create both objects:
rf = RandomForestClassifier()
classifier = LocalClassifierPerNode(local_classifier=rf)
rf = RandomForestClassifier()
classifier = LocalClassifierPerParentNode(local_classifier=rf)
rf = RandomForestClassifier()
classifier = LocalClassifierPerLevel(local_classifier=rf)
Note
The LocalClassifierPerParentNode
has a RandomForestClassifier
for each parent node existing in the hierarchy, while the LocalClassifierPerLevel
contains a RandomForestClassifier
for each level in the training labels. More information on the nuances of the hierarchical classifiers is available at the section Algorithms Overview.
- 1
Silla, C. N., & Freitas, A. A. (2011). A survey of hierarchical classification across different application domains. Data Mining and Knowledge Discovery, 22(1), 31-72.