Comparing AWS Comprehend and Azure ML on Excel

Comparing AWS Comprehend and Azure ML on Excel

In this Tutorial, I will compare AWS Computing and Azure ML on Excel

In my module “Developing Meaningful Indicators” , a classmate (Nicole) used Azure Machine Learning on Excel to conduct sentiment analysis on over 4000 Pfizer-related tweets in order to determine how most people felt about the vaccine.

She discovered that the sentiments of tweets were quite evenly spread out, with “negative” having a slight gain over “positive”. This means that the opinion amongst Twitter users are relatively mixed, having a healthy mix of both positive and negative opinions about the Pfizer vaccine. This can be seen in the graph that she posted below.

Coincidentally, I had previously also used AWS Comprehend to do sentiment analysis on a bunch of Reddit comments. In fact, I documented that process here. That actually got me asking, “Which of the AI models is more accurate?” As a computing major, I had some faith in the world of technology, and my initial hypothesis was that there will be some general trend where the two will agree with each other. In other words, in general, tweets that are lower on the sentiment scale for one AI would also be relatively low for the other, and vice versa.

The Technical Bits

My first step to answering this question was to run my own sentiment analysis using AWS Comprehend. For those who has not seen my previous post, I had used an existing AWS Educate account where I had free credits to use the services offered by AWS. The first function written was copied from my previous project, which connected to the AWS server, and send a piece of text for sentiment analysis. The response is then processed and saved. This function was actually guided by the AWS documentation here.

### script for sentiment analysis

def get_sentiment(text):
    comprehend = boto3.client(service_name='comprehend', region_name='us-east-1')
    response = comprehend.detect_sentiment(Text=text, LanguageCode='en')
    response = dict(response)
    result = {}
    result["sentiment"] = response["Sentiment"]
    result["positive"] = response["SentimentScore"]["Positive"]
    result["negative"] = response["SentimentScore"]["Negative"]
    result["neutral"] = response["SentimentScore"]["Neutral"]
    result["mixed"] = response["SentimentScore"]["Mixed"]
    result["sentiment_score"] = (result["positive"] - result["negative"]) / 2
    return result

Secondly, code was written to process the data that was in the CSV file, and write the results into another CSV file.

### get sentiment results

try:
    result = get_sentiment(body)
except botocore.exceptions.ClientError as e:
    print(e)
    result = 'no-go'
    while (result != "ok" and result != 'skip'):
        print("type 'ok' or 'skip' to continue")
        result = input()
    if (result == 'skip'):
        skipped += 1
        print("error occurred with sentiment analysis, skipping row")
        continue
    result = get_sentiment(body)
except:
    skipped += 1
    print("error occurred with sentiment analysis, skipping row")
    continue

### write to csv
row = ['0','1','2','3','4','5','6',result["sentiment"], result["positive"], result["negative"], result["neutral"], result["mixed"], result["sentiment_score"]]
print(row)
writer.writerow(row)
print("scanned and accessed data index", count)

Along this process, a huge stumbling block I had faced was the presence of “unclean data”. The CSV data set, I believed, was directly scraped off Twitter. However, that meant that there were an abundance of trash characters, and those that neither AWS nor Python could properly process. As seen from the screenshot below, there were plenty of trash characters that affected the Python script.

azure-machine-learning aws-comprehend excel azure ml aws

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Hire Machine Learning Engineer | Offshore Machine Learning Experts

We are a Machine Learning Services provider offering custom AI solutions, Machine Learning as a service & deep learning solutions. Hire Machine Learning experts & build AI Chatbots, Neural networks, etc. 16+ yrs & 2500+ clients.

Hire Machine Learning Developer | Hire ML Experts in India

We supply you with world class machine learning experts / ML Developers with years of domain experience who can add more value to your business.

Azure Machine Learning Service

In a series of blog posts, I am planning to write down my experiences of training, deploying and managing models and running pipelines with Azure Machine Learning Service.

5 Latest Technology Trends of Machine Learning for 2021

Check out the 5 latest technologies of machine learning trends to boost business growth in 2021 by considering the best version of digital development tools. It is the right time to accelerate user experience by bringing advancement in their lifestyle.

Beginner’s guide to Azure Machine Learning Studio using custom dataset

In simple terms, Machine Learning uses some set of algorithms to learn different examples of similar data to perform a specific task for a particular domain.