This quickstart shows you how to use AutoML Natural Language Sentiment Analysis to create a custom machine learning model for analyzing the prevailing emotional attitude in a text. It trains a custom model using an open dataset from FigureEight that analyzes Twitter mentions of the allergy medicine Claritin.
Training data for AutoML Natural Language Sentiment Analysis consists of representative samples of the type of content you want AutoML Natural Language Sentiment Analysis to analyze, each labeled with a value indicating how positive the sentiment is within the content. See Preparing your training data for information.
Set up your project
Before you can use AutoML Natural Language Sentiment Analysis, you must enable it for your project. Open the AutoML Natural Language Sentiment Analysis UI and select your project from the drop-down list in the upper right of the title bar. (You must have at least roles/editor access to the project.) The application walks you through the necessary steps, which are also described in Before you begin.
Create a dataset
Download the CSV file containing the sample data for training the model.
Visit the AutoML Natural Language Sentiment Analysis page and select the Launch app link in the AutoML Sentiment Analysis box.
Click the New Dataset button in the title bar.
On the Create dataset page, enter a name for the dataset and select Sentiment analysis as the objective.
Under Import text items, select Upload a CSV file from your computer, and choose the file you downloaded at step 1.
Under Sentiment score, choose 4 as the Maximum sentiment score.
The sentiment value is an integer ranging from 0 (relatively negative) to a maximum value of your choice (positive). The sample dataset uses sentiment values from 0 to 4.
Click Create dataset.
You're returned to the Datasets page; your dataset will show an in progress animation while your documents are being imported. This process should take approximately 10 minutes per 1000 documents, but may take more or less time.
After the dataset is successfully created, you will receive a message at the email address you used to sign up for the program.
Train your model
After your training data has been successfully imported, select the dataset from the dataset listing page to see the details about the dataset. The name of the selected dataset appears in the title bar, and the page lists the individual text items in the dataset along with their sentiment values. The navigation bar along the left summarizes the number of data items and enables you to filter the item list by sentiment value.
When you are done reviewing the dataset, click the Train tab just below the title bar. Click the Start Training button to begin training the model.
Training a model can take several hours to complete. After the model is successfully trained, you will receive a message at the email address you used to sign up for the program.
After training, the bottom of the Train page shows high-level metrics for the model, such as its precision. To see more details, click the Evaluate tab.
Use the custom model
After your model has been successfully trained, you can use it to evaluate sentiment using your custom model. Click the Predict tab just below the title bar, enter text into the text box, and click Predict. AutoML Natural Language Sentiment Analysis evaluates the text using your model and displays the predicted sentiment value.
To avoid unnecessary Google Cloud Platform charges, use the GCP Console to delete your project if you do not need it.