0 / 0
Emotion classification block
Emotion classification block

Emotion classification block

The Emotion model in the Watson Natural Language Processing classification block classifies the emotion in the input text.

Block name


Supported languages

  • English and French


The Emotion classification model is a pre-trained document classification model for the task of classifying the emotion in the input document. The model identifies the emotion of a document, and classifies it as:

  • Anger
  • Disgust
  • Fear
  • Joy
  • Sadness

Unlike the Sentiment model, which classifies each individual sentence, the Emotion model classifies the entire input document. As such, the Emotion model works optimally when the input text to classify is no longer than 1000 characters. If you would like to classify texts longer than 1000 characters, split the text into sentences or paragraphs for example and apply the Emotion model on each sentence or paragraph.

A document may be classified into multiple categories or into no category.

Capabilities of emotion classification based on an example
Capabilities Example
Identifies the emotion of a document and classifies it "I'm so annoyed that this code won't run --> anger, sadness

Dependencies on other blocks


Code sample

import watson_nlp

# Load the Emotion workflow model for English
emotion_model = watson_nlp.load(watson_nlp.download('ensemble_classification-wf_en_emotion-stock'))

# Run the Tone model 
emotion_result = emotion_model.run("I'm so annoyed that this code won't run")

Output of the code sample:

  "classes": [
      "class_name": "anger",
      "confidence": 0.6074999913276445
      "class_name": "sadness",
      "confidence": 0.2913303280964709
      "class_name": "fear",
      "confidence": 0.10266377929247113
      "class_name": "disgust",
      "confidence": 0.018745421312542355
      "class_name": "joy",
      "confidence": 0.0020577122567564804
  "producer_id": {
    "name": "Voting based Ensemble",
    "version": "0.0.1"

Parent topic: Watson Natural Language Processing block catalog