-
Notifications
You must be signed in to change notification settings - Fork 2
Machine Learning: Making predictions
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 ;)
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.
Copyright (C) 2020 Ajitesh Panda, Ankit Maity Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".