Text classification with over 10 thousand classes with at least two features

Jean1: <p>hello everyone, I want to do a text classification using deep learning.<br>
I have a dataset with at least two characteristics that are texts in the columns. I have more than 10 thousand classes. if anyone can suggest a method.</p>

akuysal: <p>I have experience in text classification for many years. 10 thousand classes are too much for both text classification and also for pattern recognition. I hope you have enough samples in your dataset for training. LSTM models are known as successful for text classification. I can recommend employing these deep learning approaches.</p>

vdw: <p>Well, every Seq2Seq task where you predict an output sequence can be considered a classification task where the goal is to predict the next word from a vocabulary. And the vocabulary can easily be of size 10k+. But yeah, it typically require a huge amount of data to generalize well.</p>

Jean1: <p>Hi <a class="mention" href="/u/akuysal">@akuysal</a> Thanks for your help. I managed to find distinct subsets in the data. But these subsets are very unbalanced. The number of classes within each subset is different from one subset to another. I want to classify the data according to the subsets and then classify the data of each subset according to the classes contained in each subset. Is it possible to apply SMOTE? How big can I estimate the data size for my deep learning model to train better?</p>

akuysal: <p>I haven’t applied SMOTE (Synthetic Minority Oversampling Technique) before. As far as I understand, you are trying to perform a kind of hierarchical text classification similar to 20 newsgroups dataset. In general, my aim was to propose a framework that also works on imbalanced data. I mostly worked with traditional machine learning algorithms rather than deep learning. Ensemble classification approaches can also be applied to unbalanced data in addition to over/under sampling methods. I couldn’t exactly understand what kind of texts (probably they are short texts) you have. Also, what is the accuracy of the currently running system without applying SMOTE?</p>

Jean1: <p>Hi <a class="mention" href="/u/akuysal">@akuysal</a> sorry for all the time.I used several methods finally I used a Bidirectional LSTM model with more than 5000 (classes) outputs. I get about 49% accuracy.</p>

akuysal: <p>Hi <a class="mention" href="/u/jean1">@Jean1</a> , I think the accuracy is not bad for your case because there are so many classes. You may analyze confusion matrix in order to understand which classes are difficult to classify. I think it may help you to improve your model parameters.</p>

Jean1: <p>Thanks <a class="mention" href="/u/akuysal">@akuysal</a>, But I have a question how to improve the parameters of the model.</p>

J_Johnson: <p>How well is each class represented in the data? For example, if 49% of your data is 1 class, the model could just be guessing that class every time. Any class under-represented or over-represented could create a sampling bias. Ideally, you want an even amount in each class and subclass.</p>

dreidizzle: <p>Random notes but - you want a baseline to tell you are you above random or “bad”. For example, if there are 4 classes with a 100 row sample and class A has 85 rows, B 10, C 3 and D 2, you can do a bit of analysis. A random classifier will have an accuracy of 25% … On the other hand, a classifier that always predicts A will have 85%. But, if B, C, D are crucial, you need to compute other metrics like Recall or AUC or Precision. Also, you should try to have your train and test distributions almost the same …</p>

Jean1: <p>hi <a class="mention" href="/u/j_johnson">@J_Johnson</a>. Let us assume that the classes are almost in balance. But can such a model be deployed in production?</p>

J_Johnson: <p>That would depend on how well the model performs and if that accuracy is suitable to the task.</p>
<p>But my point in the above comment is that if the superficial accuracy metric is applied without a deeper understanding of the train/test data, one could be misled into thinking a model has high accuracy that does not.</p>
<p>Take, for instance, a simple cat/dog classification model. The model gets 80% accuracy. However, upon further investigation, it turns out the data is 20% cats and 80% dogs. And so the model just learned to guess “dog” every time. That model wouldn’t be suitable for anything.</p>
<p>At any rate, if a model is determined to be doing well on a balanced dataset, the use case will determine how well is good enough for that particular use.</p>