Rule Engine Node - way to generalize over columns

Hello,

I am trying to create a workflow that creates a binary variable for several columns in a table. I would like to do this in a generalized way, because the names of those columns may change, but the rule will remain the same (eg. the_column >= 10 => 1, looped over a subset of the columns in a table, and writing the binary variable back into those columns)

I looked at the Rule Engine for this, but seems would require me to specify the name of the column. Also, I would only be able to predict one column at a time this way. Any suggestions on how to use knime to loop (and generalize the column name) to solve this problem?

Thanks Much,

dsiegel

 

 

 

You could use column list loop start to process one column at a time.

First use a column filter to remove the columns which will not be processed in the way you describe. then use column rename regex to rename the column to a standard name, I.e so the column is just called COLUMN.

now use rule engine node on this column called COLUMN.

now use column rename regex again, this time for the renaming, specify it from the flow variable tab as on each loop iteration using the column list loop start, the variable is the name of the original column name. So you will now end up with the column back to its original name.

finally complete the workflow with a loop end (column append) node. Now use a joiner node with your table right at the start to get your remaining columns back. 

hope this works for you, I'm unsure of a way to process all columns together without looping.

simon.

Have you tried the Bitvector Generator node? (Splitting the bitvector back to columns probably will come in the next release of KNIME.)

Cheers, gabor

Can you specify how to configure the second column rename regex please? I don’t get it…

Hi all!

Now there is Column Expressions node or Math Formula (Multi Column) node which makes this much easier and pretty much loopless and regexless :slight_smile:

Br,
Ivan

2 Likes

How ever this option converts only Integer value columns

1 Like

Hi there,

Column Expressions node can work with all types of columns while Math Formula works with number types of course.

Br,
Ivan

4 Likes

Hi,

Here is a new approach to do the same task:


Rule_Engine_Loop.knwf (24.0 KB)

:blush: