This repository aims to consolidate the work that has been done in WP10 Cluster 3: Hierarchical Text Classification of coding systems. A report in textual form, as well as code example that can be run on SSPCloud via this link has been made available. Runnable code examples can be found in exercises/demo_hierarchical_models.qmd.
This work was done by Statistics Austria and Statistics Denmark.
You can find more information about WP10 on the CROS website, its GitHub Repository and its dedicated GitHub Pages.
The report provides an overview of hierarchical classification models for text classification in official statistics. It reviews the motivation for hierarchical classification, compares different modeling approaches, discusses evaluation strategies and practical implementation considerations, and summarizes their advantages and limitations. Further, previous work done by other National Statistical Institutes are described, their results summarized and compared to the findings of the work done during the course of this project. The report serves as a reference for selecting and developing hierarchical classification systems, particularly for statistical classifications with multi-level taxonomies such as NACE, ISCO, or COICOP.
The /exercises folder contains the complete code accompanying the report. It is organized into modular notebooks and scripts that demonstrate the end-to-end workflow for hierarchical text classification, including data preparation, taxonomy handling, model training, prediction, and evaluation. The folder /exercises/R contains the implementations of all models (flat, multiple outputs, multiple levels, and hierarchical loss) desribed in the report. In /exercises/results, all example results for the four different model implementations can be found.
This repository follows the AIML4OS template provided by the Work Package 6.
The examples cover different hierarchical classification strategies and are intended as practical, reproducible implementations of the concepts discussed in the report.
The /exercises/demo_hierarchical_models.qmd can be run as a toy example, and will consecutively call all model scripts in /exercises/R. With this, all four implemented models will be trained on a toy data set and their results will be displayed. As training the models can take a few hours, the training can be disabled by setting the parameter run==F, this will only load and print the pre-trained results. run==TRUE will train each of the four models and save/print the results.
Note that since the "training data" here is only the dictionary provided by Statistics Austria, the performance is fairly decreased when compared to "real" training data.
You can open an RStudio instance on the SSPCloud containing the runnable toy examples here: