# Nest Column Loops to Create Interaction Variables

Hi,

I'm trying to create a new set of columns using two nested column loops -- and am encountering a few issues. Any chance someone could help?

The new columns should reflect every pair-wise product from two original sets of columns "I" and 'II." (What I'm trying in case relevant is to create interaction variables, which I'll later feed to a regression learner node.)

(I did see this post already, though I don't see why what I'm trying here shouldn't also work -- and so I figured I'd write.)

==The Flow I've Tried==

• (a) Column List Loop Start node #1, which includes columns from set I  -->
• (b) Column Rename (Regex) node #1, using the "currentColumnName" flow variable to rename the current column to "COLI" (I've connected the flow variable from (a) so that this should be the correct version of currentColumnName)  -->
• (c) Column List Loop Start node #2, which includes columns from set II  -->
• (d) Column Rename (Regex) node #2, using the "currentColumnName" flow variable to rename the current column to "COLII" (I've connected the flow variable from (c))  -->
• (e) Math Formula node, takes the product of values from COLI and COLII, and names the new column "INTERACTION"  -->
• (f) Column Rename Regex node #3, searching for COLII, replacing it with flow variable  "currentColumnName" (I've connected flow variables from (c))  -->
• (g) Column Rename Regex node #4, searching for COLI, replacing it with flow variable "currentColumnName" (I've connected flow variables from (a))  -->
• (h) Loop End (Column Append) node #1 (I've connected flow variables from (c))  -->
• (i) Loop End (Column Append) node #2 (I've connected flow variables from (a))

See attached the image of the flow plus the flow configuration.

===Issues I'm Facing===

First, rather than "INTERACTION," I'd like the new column name to reflect the two columns it was created from. Though to do this I believe I'd need access to flow variables from both (a) and (c). I'm not sure how I can have this, though? (First, I don't think I can connect the flow variable ports from *both* (a) and (c) into the math formula node. Even if I could, the variables would both be called "currentColumName" and so I'm not sure how I'd distinguish them?)

Second, node (g) doesn't seem to realize that I'm passing it the flow variable from (a). Instead of restoring the original column name from (a), it gives it the same column name as restored in node (f), plus a "(#1)" appended to the end.

I'm using Analytics Platform 3.1.2.

Any chance someone has an idea?

If so thanks in advance for the help --

Neil

Hi Neil,

there are different things we can improve in this workflow.

• The red flow variable ports are only necessary to control the loop here. The flow variables go via the data connections as well
• You need to join the data set once to get all combinations.
• The outer current columnname needs to be renamed so in the inner loop you know which one are you refering to.

I changed your workflow in a way that it is more generic and works with all numeric data sets.

Please let me know if I understood your problem correctly and if I can be of any further help.

Best regards,

Iris