5
$\begingroup$

Currently, I'm using Scikit-learn in Python 3.6 to classify data with a 7-8 classes (e.g. [C, A.1, A.2, B.3, B.1.1, B.1.2, B.2.1, B.2.2] represented by dark borders below) but I started realizing that there is an inherent hierarchy in these groups that could be used during classification. I was going to write my own algorithm but I don't want to reinvent the wheel if one exists.

Does an algorithm that can predict class-labels in hierarchical manner like this exist (preferably in Python)? If not, are there any examples of an approach like this being used? It reminds me of layers in a neural network but I do not have nearly enough samples for a neural net.

For example, A.1 and A.2 in Level-1 are subgroups of Level-0_A. Level-0_C has no subgroups.

enter image description here

$\endgroup$
3
  • 2
    $\begingroup$ Sorry for digging an old post, but we just released a new library called HiClass (gitlab.com/dacs-hpi/hiclass) that tries to make it easy to create local hierarchical classifiers and I will be actively supporting it. $\endgroup$
    – Fabio
    Commented Dec 14, 2021 at 18:03
  • $\begingroup$ I’ll give yours a try. I made one as well. $\endgroup$
    – O.rka
    Commented Jan 5, 2022 at 17:00
  • $\begingroup$ @Fabio I am looking for such library that supports hierarchical classfication untl I landed here. Currently using autoencoder for feature extraction and then use the trained encoder sub-model to train a random forest for classification (multiclass, 5-classes). Is it possible to adopt this architecture in your library (base learning: autoencoder, meta-learner: random forest)? $\endgroup$
    – arilwan
    Commented Feb 22, 2023 at 14:28

3 Answers 3

6
$\begingroup$

I couldn't find an implementation of Hierarchical Classification on scikit-learn official documentation. But I found this repository recently. This module is based on scikit-learn's interfaces and conventions. I hope this will be useful.

https://github.com/globality-corp/sklearn-hierarchical-classification

It's possible to install it with pip:

pip install sklearn-hierarchical-classification

A thorough usage example is provided in the repo .

$\endgroup$
4
  • $\begingroup$ Hi! If anyone was able to figure out how to use this package for deep hierarchy - please post a ling here if you could? For me it works for depth as in provided example, but I am not certain how to properly pass a deeper hierarchy $\endgroup$ Commented Aug 29, 2018 at 17:40
  • $\begingroup$ This link does not work anymore $\endgroup$
    – Snow
    Commented Sep 28, 2020 at 9:46
  • $\begingroup$ I ended making my own package: github.com/jolespin/projects/blob/main/… but I need to split it out into a separate package once I finish my dissertation. $\endgroup$
    – O.rka
    Commented Dec 14, 2021 at 18:55
  • $\begingroup$ Can this package handle custom feature sets for each sub-model? $\endgroup$
    – O.rka
    Commented Mar 9, 2023 at 17:39
0
$\begingroup$

If anyone stumbles across this, check out the package I developed to handle this type of data.

Here's the tutorial investigating antibiotic resistance

The peer-reviewed publication is Espinoza-Dupont et al. 2021

$\endgroup$
0
$\begingroup$

We just released a new library compatible with scikit-learn to create local hierarchical classifiers.

It can be easily installed with pip install hiclass or conda install hiclass. Documentation and examples can be found at https://gitlab.com/dacs-hpi/hiclass.

I hope this will be useful for future readers. :)

$\endgroup$
5
  • $\begingroup$ Can this package handle custom feature sets for each sub-model? $\endgroup$
    – O.rka
    Commented Mar 9, 2023 at 17:39
  • $\begingroup$ @O.rka, this is not supported at the moment. Out of curiosity, what would be an application for different feature sets in the local classifiers? $\endgroup$
    – Fabio
    Commented Mar 13, 2023 at 11:42
  • $\begingroup$ @Fabio I have some questions related to the package usage that I posted here: stats.stackexchange.com/q/609559/261548 $\endgroup$
    – arilwan
    Commented Mar 15, 2023 at 13:48
  • $\begingroup$ @Fabio I did it here and it worked really well: journals.plos.org/ploscompbiol/article?id=10.1371/… $\endgroup$
    – O.rka
    Commented Mar 16, 2023 at 6:56
  • $\begingroup$ @O.rka Thank you for the information! I will read through your paper and add this to the roadmap. $\endgroup$
    – Fabio
    Commented Mar 16, 2023 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.