Icon

L3 - DA Course - Session 1 - Exercise 1 - Capturing Segments - Sentiment Predictor - Lexicon

There has been no title set for this workflow's metadata.

In this exercise you'll use integrated deployment to capture segments of a workflow that builds a lexicon-based sentiment analysis predictor. These segments can then be used by a deployable workflow later on.

Session 1 - Preparing to Deploy a Workflow Exercise 01.Capturing_Segments_-_Sentiment_Predictor_-_Lexicon_BasedIn this exercise you'll use integrated deployment to capture segments of a workflow that builds a lexicon-based sentiment analysis predictor. These segments can then be used by a deployable workflow later on.
Here we read an annotated twitter dataset containing sentiments of over 14K airline reviews left by users on Twitter.
Step 1. Capturing the data preprocessing segment of the workflow. Here the most important node is Strings to Document, which formats several string columns into a single document that can be text-mined in KNIME. 1. Drag the Capture Workflow Start node to this part of the workflow. Add an input port of type table by clicking on the three dots and selecting this option. Connect the output of the CSV Reader node to its input port, and connect its output to the input port of the Duplicate Row Filter node. 2. Drag the Capture Workflow End node to this part of the workflow. Add a port to this node by clicking on the three dots and selecting this option. Connect the output of the Strings to Document node to its input port. In the node configuration, set "Custom Workflow Name" as "Data Preparation (Captured Segment)". 3. Drag the Workflow Writer node to this part of the workflow. Connect the second output of the Capture Workflow End node to its input port. In its configuration, set "Write to" option as "Relative to" and 'Current Workflow"; "Folder" as "../Workflow_Segments"; check option "Use custom workflow name"; and set "Custom Workflow Name" as "01.Captured_Segment_1__Data_Preparation". Click "OK" and execute this node to create a workflow segment that captures this part of the workflow. 4. Connect the first output port of the Capture Workflow End node to the input of the following instance of the Capture Workflow Start node, already present in this workflow.
Join the original data with data to which sentiments were predicted. This join has the goal of guaranteeing that, in the end, we still have all the documents we had in the beginning -- even if sentiments were not predicted for all of them. Documents with no sentiment words, for example, get filtered out by the predictor, but with this last join we make sure that they are still part of the output of this workflow (and they will have 'neutral' as associated sentiment class).
Calculate a Sentiment Score based on the Number of Positive and Negative Words and Classify Documents based on the Score. The sentiment score is calculated by (number of postive words - number of negative words) divided by (number of postive words + number of negative words). If the score is negative, the document is classified as negative; if the score is positive, it is classified as positive; and if it is equal to 0, it is classified as neutral.
Here we capture a metanode that tags words based on their sentiment. Non-tagged words get filtered out in the end.
Scorer. Here we use the "Scorer" node to check how well our lexicon-based predictions match the annotated data. The performance is not very good because this approach is a bit too simplistic.
Step 2. Creating a shared component that counts the number of positive and negative words per document. This component encapsulates the counting of sentiment words per document (e.g., tweet), separated by class.1. Pressing 'Shift' and using your mouse's left-click button, select nodes starting from Bag of Words Creator all the way to the Missing Value node.2. Right-click and select option "Create Component..." and then name it Numbers of Positive and Negative Words per Tweet.3. Right-click the newly created component, go to option "Component" and then click option "Share...". Navigate until you find folder "Components" under "Session 1 - Exercises", choosing it as the location for your component. Select option "Include input data with component" and press 'OK'.4. Again, right-click the newly created component, go to option "Component" and then click option "Change Link Type...". Select option "Create workflow-relative link" and press 'OK'.
Scorer
Start capturingjoiningsegment intoa workflow
Capture Workflow Start
Calculate Scores
Filtered words
Bag Of Words Creator
Create id column
RowID
Convert strings to to documents
Strings To Document
Kaggle Dataset N=14640 Tweets from consumers to airlines
CSV Reader
End capturingworkflow segment
Capture Workflow End
Write captured workflow
Workflow Writer
Join Sentiment Predictions and Original Data
Table Validator
End capturingworkflow segment
Capture Workflow End
Tags To String
Start capturingword taggingsegment intoa workflow
Capture Workflow Start
Duplicate Row Filter
Column Filter
Write capturedworkflow
Workflow Writer
By documents via sentiments
Pivot
Missing Value
Tag Words as Positive or Negative
TF absolute
TF

Nodes

Extensions

Links