Traditionally we’ve considered Excel a tool to be used only with relatively small, structured (i.e. rows with columns of consistent datatypes, etc.) data:
However, the typical “rules” about what Excel can and can’t do are getting blurrier as more features are added — particularly when it comes to artificial intelligence and machine learning (AI/ML) features. For example, we can use Excel to detect the sentiment found in a series of text reviews. Let’s find out how:
This dataset contains restaurant reviews to classify as positive, negative, or neutral. Manually assessing a few reviews isn’t a problem, but it becomes challenging with thousands or more. To automate this task, we’ll use Azure’s text analytics features.
What is sentiment analysis and why use it?
Sentiment analysis is a data analysis tool that uses machine learning algorithms to decipher emotions and opinions in unstructured data. It often categorizes text as positive, negative, or neutral, enabling businesses to improve customer satisfaction and address concerns based on overall sentiment towards a brand, product, or service.
Loading the Azure ML add-in
The first step is to load the Azure Machine Learning add-in to your workbook. From the ribbon, head to Insert > Add-ins > Get Add-ins, then search for Azure Machine Learning:
Click Add, then Continue. You should now see the Azure Machine Learning add-in appear to the right of your Excel session. Click the second option in this menu, Text Sentiment Analysis (Excel Add-in Solver), to continue.
Creating the schema
Azure does all the computing needed for sentiment analysis, but expects the input data to be in a specific format, or schema. Structuring data in a machine-friendly way is essential for machine learning and AI to work accurately and efficiently.
For this particular task, we need to create three column headers in the workbook: tweet_text
, Sentiment
, and Score
. You can find these under the View Schema section of the sentiment analysis menu.
The first column header, tweet_text
, is where we input the restaurant reviews. Despite its name, this column header can handle full reviews, not just tweets. Azure’s sentiment analysis add-in will still work effectively with this column.
The Sentiment
and Score
columns will be populated by Azure’s sentiment analysis add-in.
Running the sentiment analysis
Now that we’ve set up the schema, we can define the input for sentiment analysis in the Predict section of the add-in. The input area spans cells A1:A9, including the header. Be sure to turn on “My data has headers” option.
For the output area, the results of the sentiment analysis will be returned to cell B1. Set this cell to confirm that the results will start appearing here.
After clicking on the Predict button, you will see columns B and C populated with results.
Unfortunately, this process can be glitchy at times. If you encounter any issues, double-check the schema and inputs, or try restarting Excel.
Interpreting the scores
As expected, Azure has classified each review as positive, negative, or neutral and recorded it in the Sentiment column. The third column, Score, contains a raw number from 0 to 1 generated by Azure. The higher the score, the more positive the sentiment. These scores are then categorized into negative, neutral, and positive groups.
If you’re wondering how Azure generates these scores, it’s through a complex machine learning model that only Azure can explain.
Automated tools like this are convenient, but they often lack transparency and explainability. Although undeniably powerful, these tools are not infallible. For instance, in the sentiment analysis results, rows 3 and 5 were labeled as neutral and negative, respectively, despite being negative and positive reviews upon reading.
Moral of the story: use AI to its fullest extent, but don’t let it think for you. After all, it’s got artificial intelligence, but you’ve got the real thing.
AI, unstructured data and Excel
Unstructured data is notoriously difficult to work with, although AI is well-disposed to working it. And while Excel is generally meant to work with structured data, you will likely see more applications for using it with text, images and more. The forthcoming integration of GPT-powered language modeling in Excel with Copilot is a significant step forward.
Have you work with much unstructured data in Excel? Have you ever used sentiment analysis, and for what? What AI features do you wish would come to Excel? Let me know in the comments.
Leave a Reply