Nested Loops in KNIME

Hi all,

 

I am currently struggling with nested looping in knime. I am attempting to loop through a folder of files through a file reader, then use each input from this first loop to train a decision tree, then  generate predictions for every file in that same list. I am only interested in saving the output of the prediction engine, not of the learner itself.

The problem I run into is that when I try to create a second loop within the first, I run into the error displayed below.


 

Has anyone else run into this?

 

 

Thanks,

 

Chris

It looks to me that KNIME cannot tell which Loop End node refers to which Loop Start node. Try connecting the Flow Variable output port of Node 2 to the Flow Variable input port of your Node 1222. It might (or might not) solve the issue.

Cheers,
Marco.

Hi,

the Table row to variable followed by the Variable to Table Row node looks strange to me as well. What were your goal of these two nodes?

Best, Iris

you may want to try wrapping the circled nodes into a sub-node, making sure to pass the first loop's loop variable into it. That should clarify which Loop End is to be associated with which Loop Start.

David

 

1 Like

By the way, you may want to consider using the Variable Loop End node to end both loops. The description for it is

It can be used to close loops where all the magic happens in the loop itself and no aggregated output is needed.

This does seem to fit what you are doing - the inner loops does the magic and writes the output to csv files, and nothing needs to be returned.

 

Hi Iris:

You will be my best help. I have a problem with a loop. I must to do 50 time series models. I am using a MLP Learner with an optimization loop. At the start a put a row filter to just let it go the first data to the first model and everything going on rails, but when I put the optimization loop and I changed row filter node to allow all data from different models, an error appeared saying that maybe loops/scopes not properly nested.

I deleted optimization loop and I changed for a Interval Loop, but the problem did not disappear.

Could you help me???

Thanks.

Gabriel.

Proy_TS_3.knwf (99.6 KB)
Proy_TS_4.knwf (102.4 KB)

Hi @Gabriel_Cornejo,

Happy new Year! I hope you had a great time inbetween the years :slight_smile:

Without the data it is difficult to debug. What I would do to debug is

  1. Clean the workflow, by making metanodes
  2. Remove flow variable connection from outside to the inside of the loop, instead connect those flow variables before the loop start node
  3. Collapse first the inside loop into a wrapped meta node (including start and end)
  4. If this does not help, add more flow variable connections to make the order of the loop very fixed.

I hope this helps! If not, I would need some dummy data to repair the workflow.

Best, Iris

Dear Iris.

Happy New Year for you too!!!

Proyecto Forecast 5 sku Automático.zip (2.7 MB)

I tried to do the things you told me. At first I cleaned a little the workspace. Then I create two Metanodes, but it was unsatisfactory.

The workspace read a base of products (SKU) by hand one by one. Then apply an optimization loop to reach the best model of time series with MLP. Once you have the best, you apply it to obtain R2 and RMSE to evaluate the model setting.

My idea is to create a loop to be capable of deliver to the flow one by one automatically those 5 prodcutos or SKU that are written in the table creator, but then the problem appears.

I enclosed the whole workflow, could you tell me if my idea can be solved??? And what do I have to change???

Thanks for all your support.

Gabriel.