Icon

03 Workflow Control

Workflow Control - Exercise

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

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 if the number of rows is 0. Don'tcollect rows from the last iteration, but add the iteration column. Task 2: Group Loop1. Execute the Missing Value node and start a group loop where each subgroup is defined by the neighborhood 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 it to the top Bar Chart node. Youcan 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 ofthe switch node with this flow variable.5. Encapsulate the nodes into a component. Configure the component and open its interactive view. Global Data SuperStoreNr of nights:Current iteration+1Discount 0Calculate priceTable dimensionsRemove where price is 100 or lessRegion and Postal codeAverage priceTop: Price=0 Replace price columnRemove rowswith missing valuesin group columnsStop whennumber of rowsis zeroCSV Reader Math Formula(Variable) Row Filter Math Formula Row Filter Extract TableDimension Row Filter Group Loop Start GroupBy Row Splitter ConstantValue Column Missing Value Table Rowto Variable Visualize prices by neighborhoodand selected category Variable ConditionLoop End Generic Loop Start Concatenate Loop End 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 if the number of rows is 0. Don'tcollect rows from the last iteration, but add the iteration column. Task 2: Group Loop1. Execute the Missing Value node and start a group loop where each subgroup is defined by the neighborhood 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 it to the top Bar Chart node. Youcan 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 ofthe switch node with this flow variable.5. Encapsulate the nodes into a component. Configure the component and open its interactive view. Global Data SuperStoreNr of nights:Current iteration+1Discount 0Calculate priceTable dimensionsRemove where price is 100 or lessRegion and Postal codeAverage priceTop: Price=0 Replace price columnRemove rowswith missing valuesin group columnsStop whennumber of rowsis zeroCSV Reader Math Formula(Variable) Row Filter Math Formula Row Filter Extract TableDimension Row Filter Group Loop Start GroupBy Row Splitter ConstantValue Column Missing Value Table Rowto Variable Visualize prices by neighborhoodand selected category Variable ConditionLoop End Generic Loop Start Concatenate Loop End

Nodes

Extensions

Links