somehow I am stuck.
I have a list of 5 values and I want KNIME to randomly pick one of those 5 every time a workflow is executed.
I tried to play around with the random numbers generator but don’t know how to match the resulting number with the existing data table.
The solution seems to be “within reach” but I just can’t see it
KNIME_random_pick.knwf (6.0 KB)
Thank you in advance!
Uh Datageneration question are my favourites.
Checkout this node:
There is actually a paper about those nodes, you can find it here:
hmmm… I still don’t get it.
I thought that the initial random numbers generator would be necessary. However, with the random matcher it is not. Using this random number generating tool was just an idea by me but is in no way necessary.
In the end what I need is a random value from the lower table (the “rnd name table”).
Are you saying that you want to end up with:
- a table with 1 row which is the randomly selected row from the bottom table
- or a table with 5 rows, each row containing the 1 randomly selected value
- or a table with 5 rows, 4 rows containing missing values and 1 row (at the same index as in the source table) with the random value
Hi @kowisoft -
What about something like this? It’s clunky, but it gave me an opportunity to play around with some of the nodes highlighted by Iris above:
SelectRandomValueExample.knwf (10.3 KB)
option 1: a table with 1 row which is the randomly selected row from the bottom table
Thank you, that looks pretty good. The problem is the config of the random number assigner. I used the node as well but realized, that the values to choose from (the bottom table in my example) will change. This “selection” will be executed in a loop for each “data set” which in itself than has 5 (or whatever) values. Sorry, if I didn’t mention that before.
The solution provided by @ScottF is fine, just add a Domain Calculator before the Random Number Assigner and your problem is solved.
Yes, I did missunderstood your question.
But as another idea, you could use the Row Sampling node. Just use random sampling and set it absolute to one
Thank you @ScottF @armingrudd and @Iris
Both solutions work.
See below the final workflow
KNIME_random_pick.knwf (14.5 KB)
The one thing I don’t understand fully is what the Domain Calculator does…
This nodes finds all the available categories in the current input dataset, hence the categories get updated for the Random Number Assigner node each time the nodes are executed.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.