Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this article

Table of Contents
maxLevel2
absoluteUrltrue

...

We design the Data Preparation pipeline as shown below:

This pipeline contains the following key Snaps:


Snap LabelSnap NameDescription
1ZipFile ReadZipFile ReadReads the Twitter dataset containing 1,600,000 tweets extracted using the Twitter API.
2Select FieldsMapperIdentifies all sentences in the dataset that have been tagged 'negative' or 'positive'.
3TokenizerTokenizerBreaks each sentence into an array of words, of which two copies are made.
4Common WordsCommon WordsComputes the frequency of the 200 most common words in one copy of the array of words.
5

Write Common Words

File Writer

Writes the output of the Common Words Snap into a file in SLFS.

6Bag of WordsBag of WordsConverts the second copy of the array of words into a vector of word frequencies, whose rows are then shuffled to ensure that the unsorted dataset can be used in a variety of model-creation algorithms.
7Write Processed DatasetFile WriterWrites the processed dataset received from the Bag of Words Snap to SLFS.

Key Data Preparation Snaps

Anchor
ZFR
ZFR
ZipFile Read

This Snap reads the Twitter dataset, saved as a ZIP file.

Image RemovedImage Added

Expand
titleOutput preview

The Pipeline then parses the data retrieved from the file as a CSV using a CSV Parser Snap:

Note

The property labeled field001 captures the nature of the response that was captured by the people who originally tagged each sentence in the dataset. Here, the value 0 implies a negative polarity, and 1 implies a positive polarity.


...

The Build Model Pipeline is designed as shown below:

This Pipeline contains the following key Snaps:


Snap LabelSnap NameDescription
1Read Processed DatasetFile ReaderReads the processed Twitter dataset created by the Data Preparation Pipeline.
2AutoMLAutoMLRuns specified algorithms on the processed dataset and trains the model that offers the most reliable and accurate results.
3Write ModelFile WriterWrites the model identified and trained by the AutoML Snap to a file in the SLFS.
4Write LeaderboardFile WriterWrites the leaderboard, a table listing out the top models built by this Snap display in the order of ranking, along with metrics indicating the performance of the model.
5Write ReportFile WriterWrites the report generated by the AutoML Snap to the SLFS. This report describes the performance of each of the top-five algorithms evaluated by the AutoML Snap.

Key Build Model Snaps

Anchor
RPD
RPD
Read Processed Dataset

...

OutputDescriptionScreenshot (Click to expand)
Output0: Model

This is the model that the AutoML Snap determines offers the most accurate and reliable sentiment analysis.

Anchor
WLB
WLB
Output1: Leaderboard

A document that contains the leaderboard. All the models built by this Snap display in the order of ranking along with metrics indicating the performance of the model.

Anchor
WRT
WRT
Output2: Report
document that contains an interactive report of up to top-10 models. 

The Twitter Sentiment Analysis Pipeline

This Pipeline takes the input sentence sent through the web UI and uses the model created by the Pipelines discussed above to predict the sentiment of the input sentence.

This Pipeline contains the following key Snaps:


Snap LabelSnap NameDescription
1Sample RequestJSON FormatterProvides a sample request for the purpose of this use case.
2Extract ParamsMapper

Isolates the input text from the rest of the properties associated with the input sentence.

.
3TokenizerTokenizerBreaks the input text into a array of tokens.
4Read Common WordsFile ReaderReads the array of common words that you had saved in the Data Preparation Pipeline.
5Bag of WordsBag of WordsCreates a vector made out of the words that are present in both the input sentence and the list of common words.
6Read ModelFile ReaderReads the model that you had saved from the Build Model Pipeline.
7PredictorPredictorDetermines the polarity of the input sentence using the Bag of Words input vector and the model. It also outputs the confidence levels in its predictions.
8Prepare ResponseMapperPrepares a response that will be picked up by the Ultra Task and sent back to the web application UI.

Key Sentiment Analysis Snaps

Anchor
SR1
SR1
Sample Request

This example uses a JSON Generator Snap to provide a sample request; but when you create and run the web application, the Pipeline shall receive the input sentence through the open input view of the Filter Snap.

Image Modified


Note

The $token property indicates that the data coming into the Pipeline is from the web application. That is why you have the Filter Snap, which checks for the string "snaplogic_ml_showcase" and filters all those inputs that do not contain this string. 

...

You use this Mapper Snap to prepare a response that will be picked up by the Ultra Task and sent back to the web application UI:


Downloads

Multiexcerpt include macro
namedownload_instructions
pageOpenAPI

Attachments
patterns*.slp, *.zip

...