Hi @ipazin @aworker , while we’re waiting for confirmation from @Angel_Villa , I thought that finding combinations for the positives was quite an interesting challenge.
So, I put something together for this - note, it will also work if no combination is needed, which basically is a combination of 1 item, so it will still work.
I made use of Python, since the Python script since I it has a library to generate all combinations of a given list.
The workflow looks like this:
This is actually a v1.1 of my workflow - I’ll explain what’s the difference between 1.0 and 1.1.
Before going into details, here’s the results.
First, the input data:
The difference between v1.0 and v1.1 relates to the case of F. When I built v1.0, the approach was that the Python script would retrieve the combinations for me, and then in Knime, I would exclude the rows whose values are in the combination. This works, however, the issue is that when you have the value more than once in the column, then you are in trouble.
For example, say you have something like this:
The combination correctly returns [7,3]. However, when trying to exclude 7 and 3, it would actually exclude all rows with 7 and all rows with 3. I could not find a way in Knime to do a row filter but only on 1 occurrence.
But it’s also a bit more complicated than that. For example, let’s say I have this case (and that’s exactly what F is):
The combination correctly returns [5,5]. So not only I want to find only 1 occurrence, but it has to be 1 occurrence per element of the combination. So I need 1 occurrence of 5 (the first 5), and 1 occurrence of 5 (the second 5).
As a result, I actually implemented the removal of the elements directly in Python, because the method list.remove() allows you to remove only 1 occurrence of it.
Of course, the best way to check that the workflow works is to check the sum of the original data and sum of the processed data (they should both be the same):
Sum after process:
Here’s my workflow: Eliminate rows that sums up to zero.knwf (47.6 KB)