# Twitter BERT Sentiment Analysis AI Blueprint

# Batch-Predict

Sentiment analysis is used to classify text and determine the sentiment or opinion of a customer’s message. This Twitter BERT sentiment-analysis model can predict whether a person’s Tweets are positive or negative by extracting meaning and designating a sentiment.

# Purpose

Use this batch blueprint to deploy a Twitter sentiment-analysis model in batch mode, which analyzes and predicts Tweeted sentiments according to your data and application. The blueprint outputs CSV-formatted batch results that provide customer sentiment predictions from their Tweeted messages.

# Deep Dive

The following flow diagram illustrates this batch-predict blueprint’s pipeline: Deep Dive

# Flow

The following list provides a high-level flow of this blueprint’s run:

  • In the Twitter Connector, the user provides values for the following keys: token, term, dataset, output _file, max_twitts, end_point, and days_back
  • In the FT Batch Predict task, the user provides locations for input_file and model_path, result_path and text_column
  • The blueprint outputs a single CSV file with Tweets and their analyzed sentiments

# Arguments/Artifacts

For more information on this blueprint’s task, its inputs, and outputs, click here.

# Twitter Connector Inputs

  • --token is the token to access a user’s Twitter account.
  • --term is the desired Twitter term/topic to analyze. Default: Worldcup.
  • --dataset is the dataset name. Default: Worldcup.
  • --output _file is the name of the output CSV file. Default: twitts_worldcup.csv.
  • --max_twitts is the maximum number of posts to analyze. Default: 10.
  • --end_point is the desired endpoint to download posts. Default: recent.
  • --days_back is the desired number of days to analyze. Default: 3.

# Twitter Connector Outputs

  • --twitts_<dataset-name>.csv is the CSV file the connector outputs. Default: twitts_worldcup.csv.

# FT Batch-Predict Inputs

  • --input_filename (string, required) is the path to a local labeled file containing the data to be used for training and validation.
  • --model_path (string) is the path to a saved model/checkpoint/event. Default: ./checkpoint-50.
  • - -text_column (string) is the column including text for sentiment analysis. Default: text.

# FT Batch-Predict Outputs

  • --result_path is the name of the CSV file that contains the sentiment prediction results.

# Instructions

NOTE

The minimum resource recommendations to run this blueprint are 3.5 CPU and 8 GB RAM.

Complete the following steps to run this pretrained sentiment-analysis model in batch mode:

  1. Click the Use Blueprint button. The cnvrg Blueprint Flow page displays. Use Blueprint

  2. Click the Twitter Connector task to display its dialog. Twitter Params

    • Within the Parameters tab, set the following Key-Value pair information:
      • Key: token − Value: enter the token to access Twitter
      • Key: term − Value: enter the desired Tweeted term
      • Key: dataset − Value: enter the dataset name
      • Key: output _file - Value: provide the name of the output CSV file
      • Key: max_twitts − Value: enter the maximum number of posts to analyze
      • Key: end_point − Value: enter the desired endpoint to download posts
      • Key: days_back − Value: enter the number of days to analyze
    • Click the Advanced tab to change resources to run the blueprint, as required. Twitter Advanced
  3. Click the FT Batch-Predict task to display its dialog.

    • Within the Parameters tab, provide the following Key-Value pair information: Batch Params
      • Key: input_filename − Value: provide the path to the Twitter data file in the following format: /input/twitter_connector/twitts_worldcup.csv
      • Key: model_path − Value: provide the path to a saved model output in the following format: ./checkpoint-50
      • Key: --text_column - Value: provide the column including text for sentiment analysis using the default text
      • Key: result_path - Value: provide the results path, with the default being /cnvrg/
    • Click the Advanced tab to change resources to run the blueprint, as required. Batch Advanced
  4. Click the Run button. Run

    The cnvrg software deploys a Twitter sentiment-analysis model that predicts customer sentiments from their Tweeted messages.

  5. Track the blueprint’s real-time progress in its Experiments page, which displays artifacts such as logs, metrics, hyperparameters, and algorithms. Progress

  6. Select Batch Predict > Experiments > Artifacts and locate the batch output CSV file. Artifacts

  7. Select the prediction_result.csv File Name, click the Menu icon, and select Open File to view the output CSV file. CSV

A pretrained BERT model that can analyze sentiments in Twitter Tweets has now been deployed in batch mode. For information on this blueprint's software version and release details, click here.

# Connected Libraries

Refer to the following library connected to this blueprint:

Refer to the following blueprints related to this batch blueprint:

Last Updated: 1/17/2023, 10:52:15 PM