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 literature1, which are the local-classifier-per-node-overview
, local-classifier-per-parent-node-overview
and local-classifier-per-level-overview
.
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
:
python
from hiclass import LocalClassifierPerNode from sklearn.ensemble import RandomForestClassifier
python
from hiclass import LocalClassifierPerParentNode from sklearn.ensemble import RandomForestClassifier
python
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:
python
rf = RandomForestClassifier() classifier = LocalClassifierPerNode(local_classifier=rf)
python
rf = RandomForestClassifier() classifier = LocalClassifierPerParentNode(local_classifier=rf)
python
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
.
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.↩