text_classification()
Perform inference with a trained Emotion Detection model, on a single input string or a list of input strings. For each input string, this will return the predicted class label, which is one of the classes that the model was trained on.
Warning
Prior to perform inference with this method, you must train a model using the
emotion_detection.train() method. If you have
not trained a model yet, calling this method will either raise an error or return
unreliable results.
Arguments
- text str | list[str]
A string or a list of strings to classify. The model will return a label for each input string.
Response
A list[dict], each dict containing a "label" key with the predicted label for
the corresponding input string, and a "score" key with a float value representing
the model's confidence in its prediction.
- Python
from artifex import Artifex
# IMPORTANT: Make sure to train your Text Classification model first using the
# text_classification.train() method, before performing inference with it. If
# you have not trained a model yet, calling this method will either raise an
# error or return unreliable results.
text_classification = Artifex().text_classification
print(text_classification("How are you doing?"))
- Response
[{'label': '<LABEL_NAME>', 'score': '<CONFIDENCE_SCORE>'}]