top of page
Writer's pictureAlibek Jakupov

Customizing your Azure ML environment. Episode 3 : Vader Sentiment Analyzer on Azure ML Studio

Updated: Nov 19, 2021



“Luke, I Am Your Father”

And here is the ending article of our 3-act play named: customizing your AML environment.

We have already learnt how to install custom python and R packages, so let’s try to write a small application as AML Studio experiment.

For instance, let’s create our own Sentiment Analysis experiment in AML Studio. In this experiment we will use vader sentiment analyzer.

First, let’s download the vader wheel or official tar.gz from pypi. Now zip and upload the package as the dataset. We are now able to analyze our textual data in Azure ML.


Here is the experiment screenshot.

And here is the python code.


from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
import pandas as pd

# The entry point function can contain up to two input arguments:
#   Param<dataframe1>: a pandas.DataFrame
#   Param<dataframe2>: a pandas.DataFrame
def azureml_main(dataframe1, dataframe2=None):
    analyzer = SentimentIntensityAnalyzer()
 #two arrays containing sentiment score(from -1 to 1) and sentiment result (Negative, Postive, Neutral)
 #that is to be bound to the output dataframe
    sentiment_score = []
    sentiment_result = []

 for comment in dataframe1['Context']:
        vs = analyzer.polarity_scores(str(comment))
        sentiment_score.append(vs["compound"])
 
 if eval(str(vs["compound"])) < 0:
            sentiment = 'Negative'
 elif eval(str(vs["compound"])) == 0:
            sentiment = 'Neutral'
 elif eval(str(vs["compound"])) > 0:
            sentiment = 'Positive'
 
        sentiment_result.append(sentiment)
 
    dataframe1['SentimentScore'] = sentiment_score
    dataframe1['SentimentResult'] = sentiment_result
 
 return dataframe1

And, of course, here is the package zip.

It’s been an interesting journey together, and now you have got all tools to create your powerful machine learning prototypes on Azure. Let’s the force be with you!

67 views0 comments

Commentaires


bottom of page