Icon

01.Deploying_​Sentiment_​Predictor - Solution

Deploying Sentiment Predictor - Exercise (Solution)

In this exercise you will move a workflow to production by uploading and executing it on KNIME Business Hub.

The CSV Writer node isconfigured with a LOCALmountpoint relative path.Therefore, it works locally, butfails to find the path on theserver.Change the path to workflowrelative and select the Datafolder with the path ../Data/sentiment_results.csvPULL FOR THE SOLUTION Session 2 - Deploy to KNIME Business HubExercise 01-Deploying_Sentiment_PredictorIn this exercise you will move a workflow to production by deploying it to KNIME Business Hub. 1. Read tweets.Here we read tweets that werepreviously collected with theTwitter API, and a few columnsget renamed so that we canbetter reuse shared componentsand workflow segments derivedfrom the building workflow. 2. Data Manipulation/Preparation.Here we execute a captured workflowsegment of the building workflow thatperforms some data preprocessing. The most important node in thissegment is "Strings to Document",which formats several string columnsinto a single document that can be text-mined in KNIME. 3. Use Text Mining to Tag Words with Positive andNegative Meaning based on a Dictionary.Here we execute another captured segment of thebuilding workflow -- this time, to tag words basedon their sentiment. Non-tagged words get filteredout in the end. 6. Get Original Data and Joined Sentiment Predictions. Here we execute a segment of the building workflow that joins theoriginal data with joined predictions, when they exist. Recall that if atweet/document does not have any sentiment word, it will have aneutral sentiment prediction associated with it. The quality of thesepredictions can then be evaluated by using this dataset in a webapplication or in a web service. Here, we send the output back fortesting purposes. 5. Calculate a Sentiment Score based on theNumber of Positive and Negative Words andClassify Documents based on the Score.The sentiment score is calculated by (number ofpostive words - number of negative words) dividedby (number of postive words + number of negativewords). If the score is negative it is classified asnegative, if the score is positive it is classified aspositive, and if it is equal to 0 it is classified asneutral. 4. Count the Number of Positive and NegativeWords per Document.Here we re-use a shared component alsopresent in the building workflow. Itencapsulates the counting of sentiment wordsper document, separated by class. Step 1. Uploading the workflow to KNIMEBusiness Hub0. Add the KNIME Business Hub mountpointfollowing the instructions on the slides.1. Upload the workflow group Session 2 toKNIME Business Hub, inside your space.Make sure to include Workflow_Segments,Components and Data folders.3. Schedule an execution of this workflow (2min later) and send yourself a notification onsuccessfull/unsuccessful execution.4. (Spoiler) The workflow will fail. Open theworkflow job on KNIME Business Hub andrecognize the error5. It's time to fix the bug! Edit the local copyand upload the fixed version. Create a newspace version via the browser UI.6. Execute again the workflow on KNIMEBusiness Hub and check the producedresults. 7. Export the predicted sentimentto csv.Here we write the table with the textand the predicted sentiment to acsv file. Step 2(Optional). Workflow difference1.Open the Space History from the BusinessHub Web UI2.Select the previous version3. Download the previous version of thisworkflow locally and import it to yourworkspace3.Compare the old and new version locallywith the Workflow Difference function Read tweets extractedwith the Twitter APIExecute data preparationworkflow overextracted tweetsExecute word taggingworkflow overextracted tweetsExecute result joiningworkflow overextracted tweets andsentiment predictions Numbers of Positive andNegative Words per Tweet Column Rename Calculate Scores CSV Reader CSV Writer Call WorkflowService Call WorkflowService Call WorkflowService The CSV Writer node isconfigured with a LOCALmountpoint relative path.Therefore, it works locally, butfails to find the path on theserver.Change the path to workflowrelative and select the Datafolder with the path ../Data/sentiment_results.csvPULL FOR THE SOLUTION Session 2 - Deploy to KNIME Business HubExercise 01-Deploying_Sentiment_PredictorIn this exercise you will move a workflow to production by deploying it to KNIME Business Hub. 1. Read tweets.Here we read tweets that werepreviously collected with theTwitter API, and a few columnsget renamed so that we canbetter reuse shared componentsand workflow segments derivedfrom the building workflow. 2. Data Manipulation/Preparation.Here we execute a captured workflowsegment of the building workflow thatperforms some data preprocessing. The most important node in thissegment is "Strings to Document",which formats several string columnsinto a single document that can be text-mined in KNIME. 3. Use Text Mining to Tag Words with Positive andNegative Meaning based on a Dictionary.Here we execute another captured segment of thebuilding workflow -- this time, to tag words basedon their sentiment. Non-tagged words get filteredout in the end. 6. Get Original Data and Joined Sentiment Predictions. Here we execute a segment of the building workflow that joins theoriginal data with joined predictions, when they exist. Recall that if atweet/document does not have any sentiment word, it will have aneutral sentiment prediction associated with it. The quality of thesepredictions can then be evaluated by using this dataset in a webapplication or in a web service. Here, we send the output back fortesting purposes. 5. Calculate a Sentiment Score based on theNumber of Positive and Negative Words andClassify Documents based on the Score.The sentiment score is calculated by (number ofpostive words - number of negative words) dividedby (number of postive words + number of negativewords). If the score is negative it is classified asnegative, if the score is positive it is classified aspositive, and if it is equal to 0 it is classified asneutral. 4. Count the Number of Positive and NegativeWords per Document.Here we re-use a shared component alsopresent in the building workflow. Itencapsulates the counting of sentiment wordsper document, separated by class. Step 1. Uploading the workflow to KNIMEBusiness Hub0. Add the KNIME Business Hub mountpointfollowing the instructions on the slides.1. Upload the workflow group Session 2 toKNIME Business Hub, inside your space.Make sure to include Workflow_Segments,Components and Data folders.3. Schedule an execution of this workflow (2min later) and send yourself a notification onsuccessfull/unsuccessful execution.4. (Spoiler) The workflow will fail. Open theworkflow job on KNIME Business Hub andrecognize the error5. It's time to fix the bug! Edit the local copyand upload the fixed version. Create a newspace version via the browser UI.6. Execute again the workflow on KNIMEBusiness Hub and check the producedresults. 7. Export the predicted sentimentto csv.Here we write the table with the textand the predicted sentiment to acsv file. Step 2(Optional). Workflow difference1.Open the Space History from the BusinessHub Web UI2.Select the previous version3. Download the previous version of thisworkflow locally and import it to yourworkspace3.Compare the old and new version locallywith the Workflow Difference function Read tweets extractedwith the Twitter APIExecute data preparationworkflow overextracted tweetsExecute word taggingworkflow overextracted tweetsExecute result joiningworkflow overextracted tweets andsentiment predictions Numbers of Positive andNegative Words per Tweet Column Rename Calculate Scores CSV Reader CSV Writer Call WorkflowService Call WorkflowService Call WorkflowService

Nodes

Extensions

Links