Machine Learning: Making predictions - QEDK/clarity GitHub Wiki

Once you have imported the module, you can simply use it like:

from ml.processtext import ProcessText

nlp = ProcessText()  # this is a blocking call to load the Keras model and other functionality
# And then to perform analysis:
result = await nlp.process("Some text you need to analyze!")
# This module uses async so you can enable concurrency in your real-time applications ;)

Output

The module gives you a prediction in JSON format:

{
    "ents": "<escaped_formatted_html>",
    "tf_idf": "<tf_idf>",
    "word_associations": "<word_associations>",
    "sentiment": {
    	"mood": {
		    "empty": 0.0,
		    "sadness": 0.0,
		    "enthusiasm": 0.0,
		    "neutral": 0.0,
		    "worry": 0.0,
		    "surprise": 0.0,
		    "love": 0.0,
		    "fun": 0.0,
		    "hate": 0.0,
		    "happiness": 0.0,
		    "boredom": 0.0,
		    "relief": 0.0,
		    "anger": 0.0
		},
		"polarity": 0.0,
		"subjectivity": 0.0
	}
}

Each mood has a probability score from 0-100 but the model is highly unlikely to make predictions only towards one particular mood as normal text encompasses many different emotions. These scores are generated by a machine learning model trained on a lot of data.

Polarity is assigned on a scale of [-1, 1] (most negative to most positive). Subjectivity is assigned on a scale of [0, 1] (objective to subjective). These are rule-based scores depending on presence of certain polarizing, sentimental words.

⚠️ **GitHub.com Fallback** ⚠️