Icon

03 Workflow Control - Solution

Workflow Control - Exercise (Solution)

This workflow shows a solution to a hands-on exercise in the L2-DS Introduction to KNIME Analytics Platform for Data Scientists - Advanced course

Annotations and comments
  • Task 1: Generic Loop 1. Read the New York City Airbnb data, and filter out rows where the room price is $0 2. Start a generic loop with the Generic Loop Start node 3. Create a new flow variable "nights" by adding 1 to the currentIteration flow variable 4. Filter the data to the rooms that are available for this number of nights (availability_365 column) 5. Calculate the total prices by multiplying the nights flow variable by the price per night 6. Extract the accommodations with total price $150 or less 7. Extract the number of rows as a flow variable. Use the Extract Table Dimension node. 8. Collect the filtered accommodations with the Variable Condition Loop End node. Stop the loop if the number of rows is 0. Don't collect rows from the last iteration, but add the iteration column.
  • Task 2: Group Loop 1. Execute the Missing Value node and start a group loop where each subgroup is defined by the neighborhood and room type 2. Split the data into two subsets: room price=$0 and room price>$0 3. Calculate the average price of the rooms in the latter group 4. Transform the average price into a flow variable 5. Replace the $0 room prices with this flow variable value. Use the Constant Value Column node. 6. Concatenate the two subsets back into one table 7. End the loop with a Loop End node
  • Task 3: Switch 1. Separate the provided workflow branches with an IF Switch or CASE Switch Start node 2. Collect the data from the active branch with an End IF or CASE Switch End node, and connect it to the top Bar Chart node. You can delete the bottom Bar Chart node. 3. Create a Single Selection Configuration node with two selection options: "room type" and "number of reviews" 4. Encode the flow variable into "top"/0 if room type was selected, and into "bottom"/1 otherwise. Overwrite the active port setting of the switch node with this flow variable. 5. Encapsulate the nodes into a component. Configure the component and open its interactive view.
  • Read AB_NYC_2019 data
  • Replace price column
  • Table dimensions
  • Neighborhood and room type
  • Average price
  • Calculate price
  • Nr of nights: Current iteration +1
  • Remove rows with missing values in group columns
  • availability_365
  • <150
  • Remove where price is 0
  • Top: Price=0
  • Stop when number of rows is zero
  • Show average prices
  • category
  • Bin num of reviews into 3 categories
  • Avg price by room type and neighborhood group
  • Avg price by number of reviews and neighborhood group
  • port
  • Select category

Nodes

Extensions

Links