Sentiment Class
Scores natural language text and assesses the probability the sentiments are positive.
- Inheritance
-
nimbusml.internal.core.feature_extraction.text._sentiment.SentimentSentimentnimbusml.base_transform.BaseTransformSentimentsklearn.base.TransformerMixinSentiment
Constructor
Sentiment(columns=None, **params)
Parameters
Name | Description |
---|---|
columns
|
see Columns. |
params
|
Additional arguments sent to compute engine. |
Examples
###############################################################################
# Sentiment: pre-trained transform to analyze sentiment of free-form
# text.
import pandas
from nimbusml.feature_extraction.text import Sentiment
# Create the data
customer_reviews = pandas.DataFrame(data=dict(review=[
"I really did not like the taste of it",
"It was surprisingly quite good!",
"I will never ever ever go to that place again!!",
"The best ever!! It was amazingly good and super fast",
"I wish I had gone earlier, it was that great",
"somewhat dissapointing. I'd probably wont try again",
"Never visit again... rascals!"]))
analyze = Sentiment() << 'review'
# No need to fit any real data, just a dummy call to fit() to ensure the
# column name 'review' is present when transform() is invoked
# Skip until ML.NET resolve the resouce issue with Sentiment transform
# y = analyze.fit_transform(customer_reviews)
# View the sentiment scores!!
# print(y)
# review
# 0 0.461790
# 1 0.960192
# 2 0.310344
# 3 0.965281
# 4 0.409665
# 5 0.492397
# 6 0.332535
Remarks
The Sentiment
transform returns the probability that the
sentiment of a natural text is positive. The model
was trained with the WordEmbedding and
NGramFeaturizer
on Twitter sentiment
data, similarly to the sentiment analysis part of the Text Analytics
cognitive service.
The transform outputs a score between 0 and 1 as a sentiment
prediction (where 0 is a negative sentiment and 1 is a positive
sentiment). Currently it
supports only English.
Methods
get_params |
Get the parameters for this operator. |
get_params
Get the parameters for this operator.
get_params(deep=False)
Parameters
Name | Description |
---|---|
deep
|
Default value: False
|