---
title: Sentiment analysis example
description: Apply Composable ML to capture sentiment from text.

---

# Sentiment analysis example {: #sentiment-analysis-example }

The model in this example includes reviews or tweets. The goal is to get an uplift for the model by capturing the sentiment in the text. To do this, simply [modify the blueprint](cml-blueprint-edit#access-the-blueprint-editor) (i.e., click **Copy and Edit** to start). The following is a simple blueprint.&mdash;text only&mdash;but the model could have features as well. 

![](images/cml-sentiment-example-1.png)

Hover over either the **Matrix of word-grams counts** or **Elastic-Net Classifier** nodes to see:

* The type of input required for that task.
* The type of output returned. 

For example, the **Matrix of word-grams counts** task requires the input to be of type Text and it returns a data frame with all numeric features:  

![](images/cml-sentiment-example-2.png)

To capture sentiments in a text feature for this example, hover over the **Text variables** node and click the [task selector](cml-blueprint-edit#use-the-task-selector) plus sign (![](images/icon-plus.png)). In the **Select a task** dialog box, expand **Preprocessing > Text Preprocessing** to see the options for text manipulations. (Some of these options are also available via [**Advanced Tuning**](adv-tuning), but others can only be accessed here.) Select to add **TextBlob Sentiment Featurizer**.

![](images/cml-sentiment-example-3.png)

The blueprint now shows a new node, outlined in red. When you hover over the node, you can see that it requires text:

![](images/cml-sentiment-example-4.png)

Note that the node's output is a data frame with numerical features (`Data Type: Numeric`). Because the **TextBlob Sentiment Featurizer** is a preprocessing module, you must [connect it to the model task](cml-blueprint-edit#work-with-nodes). (Hover over the TextBlob node, drag the diagonal arrow (![](images/icon-diagonal-arrow.png)) icon to the **Elastic-Net Classifier** node, and click.)

![](images/cml-sentiment-example-6.png)


The new blueprint is [ready to be trained](cml-blueprint-edit#train-new-models). (Before training, you can change the feature list or the training sample size.)

Here is the model on the Leaderboard, shown as one of the top four models. 

![](images/cml-sentiment-example-5.png)


