Icon

3 Workflow Control

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

Task 2: Group Loop1. Execute the Missing Value node and start a group loop where each subgroup is defined by theneighborhood and room type2. Split the data into two subsets: room price=$0 and room price>$0 3. Calculate the average price of the rooms in the latter group4. Transform the average price into a flow variable5. Replace the $0 room prices with this flow variable value. Use the Constant Value Column node.6. Concatenate the two subsets back into one table7. End the loop with a Loop End node Task 3: Switch1. Separate the provided workflow branches with an IF Switch or CASE Switch Start node2. Collect the data from the active branch with an End IF or CASE Switch End node, and connect itto 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 interactiveview. Task 1: Generic Loop1. Read the New York City Airbnb data, and filter out rows where the room price is $02. Start a generic loop with the Generic Loop Start node3. Create a new flow variable "nights" by adding 1 to the currentIteration flow variable4. 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 night6. 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 ifthe number of rows is 0. Don't collect rows from the last iteration, but add the iteration column. Read AB_NYC_2019dataNr of nights:Current iteration+1availability_365Calculate price<150Table dimensionsRemove where price is 0Neighborhood androom typeAverage priceTop: Price=0Replace price columnRemove rowswith missing valuesin group columnsStop whennumber of rowsis zero CSV Reader Math Formula(Variable) Row Filter Math Formula Row Filter Extract TableDimension Row Filter Group Loop Start GroupBy Row Splitter ConstantValue Column Concatenate Missing Value Table Rowto Variable Variable ConditionLoop End Generic Loop Start Loop End Visualize prices by neighborhoodand selected category Task 2: Group Loop1. Execute the Missing Value node and start a group loop where each subgroup is defined by theneighborhood and room type2. Split the data into two subsets: room price=$0 and room price>$0 3. Calculate the average price of the rooms in the latter group4. Transform the average price into a flow variable5. Replace the $0 room prices with this flow variable value. Use the Constant Value Column node.6. Concatenate the two subsets back into one table7. End the loop with a Loop End node Task 3: Switch1. Separate the provided workflow branches with an IF Switch or CASE Switch Start node2. Collect the data from the active branch with an End IF or CASE Switch End node, and connect itto 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 interactiveview. Task 1: Generic Loop1. Read the New York City Airbnb data, and filter out rows where the room price is $02. Start a generic loop with the Generic Loop Start node3. Create a new flow variable "nights" by adding 1 to the currentIteration flow variable4. 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 night6. 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 ifthe number of rows is 0. Don't collect rows from the last iteration, but add the iteration column. Read AB_NYC_2019dataNr of nights:Current iteration+1availability_365Calculate price<150Table dimensionsRemove where price is 0Neighborhood androom typeAverage priceTop: Price=0Replace price columnRemove rowswith missing valuesin group columnsStop whennumber of rowsis zero CSV Reader Math Formula(Variable) Row Filter Math Formula Row Filter Extract TableDimension Row Filter Group Loop Start GroupBy Row Splitter ConstantValue Column Concatenate Missing Value Table Rowto Variable Variable ConditionLoop End Generic Loop Start Loop End Visualize prices by neighborhoodand selected category

Nodes

Extensions

Links