I would like to create a multilabel text classification algorithm using SpaCy text multi label. I am unable to understand the following questions:

  1. How to convert the training data to SpaCy format i.e I have 8 categories
  2. After converting, how do we use that to train custom categories and apply different models

1 Answer 1


Bro. It's waste to do classification using spaCy, you can refer Deep learning techniques. But your question is different, spaCy needs dictionary format with labels Positive and negative, Here I will give sample snippet, like this frame your input data

# change input data to spaCy readable format 

train_examples = [] # it needs dict inside tuples insides dictionary (you will understand down)

for index, row in reviews_df.iterrows(): text = row['Text'] rating = row['Score']

label = {"POS": True, "NEG": False} if rating == 1 else {'NEG':True, 'POS': False}

train_examples.append( Example.from_dict(nlp.make_doc(text), {'cats': label}) )

You can refer this https://www.machinelearningplus.com/nlp/custom-text-classification-spacy/ Clearly explained, Use Bert dude, BERT is SOTA model, that gives more accurate results, See here https://analyticsindiamag.com/a-beginners-guide-to-text-classification-using-bert-features/#:~:text=what%20BERT%20is.-,What%20is%20BERT%3F,both%20left%20and%20right%20context.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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