Icon

10 Classification IV - solution

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

Text Mining Course: Preprocessing, Transformation, and Classification Models (bonus solution)

Unsupervised learning with a lexicon-driven sentiment predictor:
- Create document cells.
- Tag terms based on sentiment dictionaries.
- Extract and count positive and negative terms.
- Compute sentiment score based on the number of positive and negative terms.
- Predict sentiment labels based on score.
- Score prediction.

URL: Slides KNIME Analytics Platform Text Mining Course https://www.knime.com/form/material-download-registration

Session 3 - Preprocessing, Transformation, and Classification Models

Solution 10 - Sentiment Predictor II (Bonus)

Learning objective: In this exercise, you will further practice performing classification on an IMDB data set.


Workflow description: This workflow predicts the sentiment of movie reviews using an unsupervised approach: lexicon-driven.


You’ll find the instructions for the exercises in the yellow annotations.

Unsupervised learning: Build a lexicon-driven sentiment predictor

  1. Create document cells.

  2. Tag terms based on sentiment dictionaries with the Dictionary Tagger node.

  3. Extract and count positive and negative terms.

    • Filter terms tagged as positive and negative.

    • Generate a bag of words and and count (absolute frequency) positive and negative terms.

    • Use the Tags to String node to extract sentiment tags.

    • Use the Pivot node to sum absolute term frequency per sentiment (positive and negative) in each document.

    • Handle any missing values with 0.

  4. In a parallel branch to 3., compute absolute term frequency and use the GroupBy node to sum absolute term frequency in each document.

  5. Join the output tables of 3. and 4. with the Joiner node. Use "Document" as the join column.

  6. With the Math Formula node compute a sentiment score based on the number of positive and negative terms. Use the formula: (PositiveWords - NegativeWords)/TermFrequency

  7. Predict sentiment labels based on the score using the Rule Engine node. For example, if score is >= 0, the sentiment is positive.

  8. Score predictions.



Your Solution
Scorer
Assign negative tags
Dictionary Tagger
Sentiment score
Math Formula
Negative list
CSV Reader
Joiner
Predict sentiment based on score
Rule Engine
Color by sentiment label
Color Manager
Read imdbdataset
CSV Reader
Extract sentiment label
Category To Class
Count number of all words in documents
TF
Column Renamer
Positive list
CSV Reader
By documents via sentiments
Pivot
Missing Value
Count number of positive and negative words in document and extract terms
TF
Assign positive tags
Dictionary Tagger
Transformation of strings to documents
Document Creation

Nodes

Extensions

Links