"How to loop through all values in a nominal set"

macaronmacaron MemberPosts:3Contributor I
edited June 2019 inHelp
Hi everyone.

The Loop Values operator's wiki states throughout that it iterates over "all the possible values of the selected attribute".

In view of this, I expected the process





<宏/ >























< portSpacing端口= " sink_out 2”间隔= " 0 " / >









打印到控制台:
hello
world
But it only prints
hello
Is there a way in which I can iterate over the entire nominal set of the attribute, even those values that do not appear in the particular data currently provided?

Regards,
Kurk

Answers

  • MariusHelfMariusHelf RapidMiner Certified Expert, MemberPosts:1,869Unicorn
    Hi Kurk,

    unfortunately that is not possible. I think we even changed the behaviour such that unused values are ignored, because that is what the average user will expect.
    The only workaround is probably to use some kind of groovy scripting with the Execute Script operator to first create a data set that contains all values in the mapping, and then loop that data set.

    Best regards,
    Marius
  • macaronmacaron MemberPosts:3Contributor I
    Thank you Marius. Would it be a big change to implement a boolean parameter "include unused values" for the Loop Values operator?
    Some nominal sets are inherently defined. E.g. weekdays, months, and in some cases one needs the processing structure not to be altered by the data that happens to go through it.

    It could be an "advanced parameter" so as not to bother the average user. Do you think this would be a reasonable request or is it too custom?

    Regards,
    Kurk
  • MariusHelfMariusHelf RapidMiner Certified Expert, MemberPosts:1,869Unicorn
    That's probably too specific, because in reality we want to hide the nominal mapping from the users, not expose it, because it is only the internal implementation and could in theory vanish completely one day.

    We also have such problems, but in that case again we would create a data set that contains nothing but the loop values (e.g. days of week), loop over that data set and perform the necessary steps on the other data set.

    Best regards,
    Marius
  • macaronmacaron MemberPosts:3Contributor I
    好的。Thanks for taking the time to explain.

    Just wondering: Why is there an Add operator then? For what could it be used if the set of possible nominal values is supposed to be hidden from the user?

    Thanks,
    Kurk
  • MariusHelfMariusHelf RapidMiner Certified Expert, MemberPosts:1,869Unicorn
    To be honest, until last week I had no idea that it even exists and I have never used it before. It's probably there for compatibility reason with the previous versions.

    Best regards,
    Marius
Sign InorRegisterto comment.