My first pet ML project, so please pardon if I phrase something incorrectly. Recently I had IMDB sentiment analysis binary classification practice on Tensorflow site. Now I am keen to do multiple label classification of the abstracts in the newspapers.

I have prepared a Pandas dataframe with 2 key columns [sectors_array] and [text]. It is 10 0000 rows. There are 100 sectors overall. [sectors_array] column has 1 to 4 sectors (Same article can fall into multiple categories). Text is a string up to 500 chars. Text contains a piece of article and sectors categorize the text, i.e whether it is food, sport, cinema, politics etc.

So far I cleansed text column to remove single characters, urls, punctuation and did removal of stop words and Lemmatisation for nltk tokenized text.

For multiple sectors I added a hundred of columns with 1/0 flags for each sector.

Now what could be my direction from there in order to classify the new text to existing sector(s)? Would this big number of sectors present an issue for categorisation?

Which library should be best for the task? Tensorflow/Spacy?

Ideally I would want to present up to most probable 4 sectors for the piece of text.


1 Answer 1


I think it's always a good idea to start with a basic option. Once you have a decent basic model, you can try to improve performance with something more advanced and you would have a baseline so you know if the performance of the advanced model is really good or just ok.

In this case the basic option would be to train 100 binary classifiers, one for every label. The text could be represented as a TFIDF vector. I would suggest removing the rare words, it can significantly improve performance. Then a traditional model like Naive Bayes, Decision Trees or SVM can be used.

The number of labels by itself is not an issue, however their distribution matters, especially if some of them have very few instances (expect bad performance on these).

  • $\begingroup$ Amazing, thanks @Erwan! $\endgroup$
    – RandyMcKay
    Jan 29, 2021 at 9:06

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.