I have a Pandas DataFrame which consists of a body of text in 1 row. Each body of text is assigned labels for Category
(in 1 row) and a Topic
(in a separate row). Example of DataFrame below:
Text | Category | Topic |
---|---|---|
cognitive training ... | Category A | Topic 2 |
correlation between ... | Category F | Topic 56 |
There are 8 Categories with a total of 60 unique Topics. These Topics are not equally shared amongst the Categories, for example Category A can have Topics 1-18 and Category B can have Topics 19-27. A basic diagram has been added below demonstrating the levels.
<ROOT>
____________|______________________
/ | \ \ ...
Cat A Cat B Cat C
/ / | \ \ | \ |
1 2 3 4 5 ... 19 20 ... 28
I would like to know the best approach(s) for generating a Hierarchical Classification where both the Category
and Topic
are generated in the prediction. So if a new body of text is received both levels can be predicted e.g. Category and Topic.
I have been using TfIdf
on the body of text and how next to proceed is troubling me.
from sklearn_hierarchical_classification.classifier import HierarchicalClassifier
Attempting to use this library isnt providing me with both levels as a prediction.
Any help or ideas in implementing such a model would be really appreciated :) Many thanks!